Question

Working with DockState and AutoHide, I am looking for the following things:

  1. Find out if the DockContent is in AutoHide mode
  2. Ability to toggle between 'regular' and AutoHide mode.
  3. Trigger an event when an AutoHide dock has come into view.
  4. Trigger an event when an AutoHide dock has 'left' and is now docked back into it's tab.

Answer Wiki:

  1. 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); } }
    
  2. IsAutoHide - set: No code yet - basically iterate through the modes or use a dictionary of interchangable modes (i.e. DockBottomAutoHide to DockBottom)

  3. I have no idea, but this looks interesting, might have the idea.

  4. I have no idea.
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top