Working with DockState and AutoHide, I am looking for the following things:
- Find out if the DockContent is in AutoHide mode
- Ability to toggle between ‘regular’ and AutoHide mode.
- Trigger an event when an AutoHide dock has come into view.
- Trigger an event when an AutoHide dock has ‘left’ and is now docked back into it’s tab.
Answer Wiki:
-
IsAutoHide – get:
private WeifenLuo.WinFormsUI.Docking.DockState[] AutoHideStates = new WeifenLuo.WinFormsUI.Docking.DockState[] { WeifenLuo.WinFormsUI.Docking.DockState.DockBottomAutoHide, WeifenLuo.WinFormsUI.Docking.DockState.DockLeftAutoHide, WeifenLuo.WinFormsUI.Docking.DockState.DockRightAutoHide, WeifenLuo.WinFormsUI.Docking.DockState.DockTopAutoHide }; public bool IsAutoHide { get { return AutoHideStates.Contains(DockContent.DockState); } } -
IsAutoHide – set:
No code yet – basically iterate through the modes or use a dictionary of interchangable modes (i.e. DockBottomAutoHide to DockBottom) -
I have no idea, but this looks interesting, might have the idea.
- I have no idea.
1 is a decent way to accomplish this. The library has an internal method,
DockHelper.IsDockStateAutoHide()that does basically the same thing. This should actually be made into a public extension method and included as part of the library.2 Your solution is good.
3 & 4 would probably be best implemented as a new event in the
DockPanel:ActiveAutoHideContentChanged. You could then track the last autohide content on your own and when the event is raised you know that #3 is occurring if the new value is not null and #4 is occurring if the last known value was not null.Feel free to open a request on GitHub to have the event added.