| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:DockContent.cs
- * 2.功能描述:类文件
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 陈晓野 2014/09/01 1.00 新建
- *******************************************************************************/
- using System;
- using System.ComponentModel;
- using System.Diagnostics.CodeAnalysis;
- using System.Drawing;
- using System.Windows.Forms;
- namespace Dongke.IBOSS.PRD.Basics.DockPanel
- {
- public class DockContent : Form, IDockContent
- {
- public DockContent()
- {
- m_dockHandler = new DockContentHandler(this, new GetPersistStringCallback(GetPersistString));
- m_dockHandler.DockStateChanged += new EventHandler(DockHandler_DockStateChanged);
- //Suggested as a fix by bensty regarding form resize
- this.ParentChanged += new EventHandler(DockContent_ParentChanged);
- }
- //Suggested as a fix by bensty regarding form resize
- private void DockContent_ParentChanged(object Sender, EventArgs e)
- {
- if (this.Parent != null)
- this.Font = this.Parent.Font;
- }
- private DockContentHandler m_dockHandler = null;
- [Browsable(false)]
- public DockContentHandler DockHandler
- {
- get
- {
- return m_dockHandler;
- }
- }
- [LocalizedCategory("Category_Docking")]
- [LocalizedDescription("DockContent_AllowEndUserDocking_Description")]
- [DefaultValue(true)]
- public bool AllowEndUserDocking
- {
- get
- {
- return DockHandler.AllowEndUserDocking;
- }
- set
- {
- DockHandler.AllowEndUserDocking = value;
- }
- }
- [LocalizedCategory("Category_Docking")]
- [LocalizedDescription("DockContent_DockAreas_Description")]
- [DefaultValue(DockAreas.DockLeft | DockAreas.DockRight | DockAreas.DockTop | DockAreas.DockBottom | DockAreas.Document | DockAreas.Float)]
- public DockAreas DockAreas
- {
- get
- {
- return DockHandler.DockAreas;
- }
- set
- {
- DockHandler.DockAreas = value;
- }
- }
- [LocalizedCategory("Category_Docking")]
- [LocalizedDescription("DockContent_AutoHidePortion_Description")]
- [DefaultValue(0.25)]
- public double AutoHidePortion
- {
- get
- {
- return DockHandler.AutoHidePortion;
- }
- set
- {
- DockHandler.AutoHidePortion = value;
- }
- }
- private string m_tabText = null;
- [Localizable(true)]
- [LocalizedCategory("Category_Docking")]
- [LocalizedDescription("DockContent_TabText_Description")]
- [DefaultValue(null)]
- public string TabText
- {
- get
- {
- return m_tabText;
- }
- set
- {
- DockHandler.TabText = m_tabText = value;
- }
- }
- private bool ShouldSerializeTabText()
- {
- return (m_tabText != null);
- }
- [LocalizedCategory("Category_Docking")]
- [LocalizedDescription("DockContent_CloseButton_Description")]
- [DefaultValue(true)]
- public bool CloseButton
- {
- get
- {
- return DockHandler.CloseButton;
- }
- set
- {
- DockHandler.CloseButton = value;
- }
- }
- [LocalizedCategory("Category_Docking")]
- [LocalizedDescription("DockContent_CloseButtonVisible_Description")]
- [DefaultValue(true)]
- public bool CloseButtonVisible
- {
- get
- {
- return DockHandler.CloseButtonVisible;
- }
- set
- {
- DockHandler.CloseButtonVisible = value;
- }
- }
- [Browsable(false)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public DockPanel DockPanel
- {
- get
- {
- return DockHandler.DockPanel;
- }
- set
- {
- DockHandler.DockPanel = value;
- }
- }
- [Browsable(false)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public DockState DockState
- {
- get
- {
- return DockHandler.DockState;
- }
- set
- {
- DockHandler.DockState = value;
- }
- }
- [Browsable(false)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public DockPane Pane
- {
- get
- {
- return DockHandler.Pane;
- }
- set
- {
- DockHandler.Pane = value;
- }
- }
- [Browsable(false)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public bool IsHidden
- {
- get
- {
- return DockHandler.IsHidden;
- }
- set
- {
- DockHandler.IsHidden = value;
- }
- }
- [Browsable(false)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public DockState VisibleState
- {
- get
- {
- return DockHandler.VisibleState;
- }
- set
- {
- DockHandler.VisibleState = value;
- }
- }
- [Browsable(false)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public bool IsFloat
- {
- get
- {
- return DockHandler.IsFloat;
- }
- set
- {
- DockHandler.IsFloat = value;
- }
- }
- [Browsable(false)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public DockPane PanelPane
- {
- get
- {
- return DockHandler.PanelPane;
- }
- set
- {
- DockHandler.PanelPane = value;
- }
- }
- [Browsable(false)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public DockPane FloatPane
- {
- get
- {
- return DockHandler.FloatPane;
- }
- set
- {
- DockHandler.FloatPane = value;
- }
- }
- [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
- protected virtual string GetPersistString()
- {
- return GetType().ToString();
- }
- [LocalizedCategory("Category_Docking")]
- [LocalizedDescription("DockContent_HideOnClose_Description")]
- [DefaultValue(false)]
- public bool HideOnClose
- {
- get
- {
- return DockHandler.HideOnClose;
- }
- set
- {
- DockHandler.HideOnClose = value;
- }
- }
- [LocalizedCategory("Category_Docking")]
- [LocalizedDescription("DockContent_ShowHint_Description")]
- [DefaultValue(DockState.Unknown)]
- public DockState ShowHint
- {
- get
- {
- return DockHandler.ShowHint;
- }
- set
- {
- DockHandler.ShowHint = value;
- }
- }
- [Browsable(false)]
- public bool IsActivated
- {
- get
- {
- return DockHandler.IsActivated;
- }
- }
- public bool IsDockStateValid(DockState dockState)
- {
- return DockHandler.IsDockStateValid(dockState);
- }
- [LocalizedCategory("Category_Docking")]
- [LocalizedDescription("DockContent_TabPageContextMenu_Description")]
- [DefaultValue(null)]
- public ContextMenu TabPageContextMenu
- {
- get
- {
- return DockHandler.TabPageContextMenu;
- }
- set
- {
- DockHandler.TabPageContextMenu = value;
- }
- }
- [LocalizedCategory("Category_Docking")]
- [LocalizedDescription("DockContent_TabPageContextMenuStrip_Description")]
- [DefaultValue(null)]
- public ContextMenuStrip TabPageContextMenuStrip
- {
- get
- {
- return DockHandler.TabPageContextMenuStrip;
- }
- set
- {
- DockHandler.TabPageContextMenuStrip = value;
- }
- }
- [Localizable(true)]
- [Category("Appearance")]
- [LocalizedDescription("DockContent_ToolTipText_Description")]
- [DefaultValue(null)]
- public string ToolTipText
- {
- get
- {
- return DockHandler.ToolTipText;
- }
- set
- {
- DockHandler.ToolTipText = value;
- }
- }
- public new void Activate()
- {
- DockHandler.Activate();
- }
- public new void Hide()
- {
- DockHandler.Hide();
- }
- public new void Show()
- {
- DockHandler.Show();
- }
- public void Show(DockPanel dockPanel)
- {
- DockHandler.Show(dockPanel);
- }
- public void Show(DockPanel dockPanel, DockState dockState)
- {
- DockHandler.Show(dockPanel, dockState);
- }
- [SuppressMessage("Microsoft.Naming", "CA1720:AvoidTypeNamesInParameters")]
- public void Show(DockPanel dockPanel, Rectangle floatWindowBounds)
- {
- DockHandler.Show(dockPanel, floatWindowBounds);
- }
- public void Show(DockPane pane, IDockContent beforeContent)
- {
- DockHandler.Show(pane, beforeContent);
- }
- public void Show(DockPane previousPane, DockAlignment alignment, double proportion)
- {
- DockHandler.Show(previousPane, alignment, proportion);
- }
- [SuppressMessage("Microsoft.Naming", "CA1720:AvoidTypeNamesInParameters")]
- public void FloatAt(Rectangle floatWindowBounds)
- {
- DockHandler.FloatAt(floatWindowBounds);
- }
- public void DockTo(DockPane paneTo, DockStyle dockStyle, int contentIndex)
- {
- DockHandler.DockTo(paneTo, dockStyle, contentIndex);
- }
- public void DockTo(DockPanel panel, DockStyle dockStyle)
- {
- DockHandler.DockTo(panel, dockStyle);
- }
- #region IDockContent Members
- void IDockContent.OnActivated(EventArgs e)
- {
- this.OnActivated(e);
- }
- void IDockContent.OnDeactivate(EventArgs e)
- {
- this.OnDeactivate(e);
- }
- #endregion
- #region Events
- private void DockHandler_DockStateChanged(object sender, EventArgs e)
- {
- OnDockStateChanged(e);
- }
- private static readonly object DockStateChangedEvent = new object();
- [LocalizedCategory("Category_PropertyChanged")]
- [LocalizedDescription("Pane_DockStateChanged_Description")]
- public event EventHandler DockStateChanged
- {
- add
- {
- Events.AddHandler(DockStateChangedEvent, value);
- }
- remove
- {
- Events.RemoveHandler(DockStateChangedEvent, value);
- }
- }
- protected virtual void OnDockStateChanged(EventArgs e)
- {
- EventHandler handler = (EventHandler)Events[DockStateChangedEvent];
- if (handler != null)
- handler(this, e);
- }
- #endregion
- /// <summary>
- /// Overridden to avoid resize issues with nested controls
- /// </summary>
- /// <remarks>
- /// http://blogs.msdn.com/b/alejacma/archive/2008/11/20/controls-won-t-get-resized-once-the-nesting-hierarchy-of-windows-exceeds-a-certain-depth-x64.aspx
- /// http://support.microsoft.com/kb/953934
- /// </remarks>
- protected override void OnSizeChanged(EventArgs e)
- {
- if (DockPanel != null && DockPanel.SupportDeeplyNestedContent && IsHandleCreated)
- {
- BeginInvoke((MethodInvoker)delegate
- {
- base.OnSizeChanged(e);
- });
- }
- else
- {
- base.OnSizeChanged(e);
- }
- }
- }
- }
|