Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add ActiveAutoHideContentChanged event to DockPanel #81

Closed
wants to merge 2 commits into from

3 participants

@Lockszmith

Added ActiveAutoHideContentChanged event to DockPanel (with underlying ActiveContentChanged event in inner/private AutoHideWindowControl class)

Per recommendation from @roken in this SO question.

lockszmith and others added some commits
lockszmith Added ActiveAutoHideContentChanged event to DockPanel (with underlyin…
…g ActiveContentChanged event in inner/private AutoHideWindowControl class)
4b6671b
gsz Enhance AutoHide's OnActiveContentChanged to pass reference to previo…
…us ActiveContent
cf521a5
@lextm
Owner

Will review and test this out before next major release.

@roken roken referenced this pull request from a commit
Ryan Rastedt #81 - Add ActiveAutoHideContentChanged event
Added pull request from lockszmith to add an event to the DockPanel that
will be raised when the value of the AutoHideWindow's ActiveContent
property changes.
bd690ec
@roken roken was assigned
@roken
Owner

Merged commit 4b6671b from @Lockszmith.

The purpose wasn't obvious for cf521a5, so it wasn't included. Seemed to be dirty to pretend the content was activating/deactivating when it is shown from a hidden state (but not necessarily activated).

@roken roken closed this
@lextm lextm referenced this pull request from a commit
Ryan Rastedt #81 - Add ActiveAutoHideContentChanged event
Added pull request from lockszmith to add an event to the DockPanel that
will be raised when the value of the AutoHideWindow's ActiveContent
property changes.
202c84d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 13, 2012
  1. Added ActiveAutoHideContentChanged event to DockPanel (with underlyin…

    lockszmith authored
    …g ActiveContentChanged event in inner/private AutoHideWindowControl class)
Commits on Dec 19, 2012
This page is out of date. Refresh to see the latest.
View
27 WinFormsUI/Docking/DockPanel.AutoHideWindow.cs
@@ -82,6 +82,30 @@ private void SetActivePane()
m_activePane = value;
}
+ #region ActiveContentChanged Event
+ private static readonly object ActiveContentChangedEvent = new object();
+ public event EventHandler ActiveContentChanged
+ {
+ add { Events.AddHandler(ActiveContentChangedEvent, value); }
+ remove { Events.RemoveHandler(ActiveContentChangedEvent, value); }
+ }
+ protected virtual void OnActiveContentChanged(EventArgs e, IDockContent prevContent)
+ {
+ var activeContent = ActiveContent;
+ EventHandler handler;
+ if (null != prevContent)
+ {
+ prevContent.OnDeactivate(e);
+ }
+ handler = (EventHandler)Events[ActiveContentChangedEvent];
+ if (handler != null)
+ handler(this, e);
+ if (null != activeContent)
+ {
+ activeContent.OnActivated(e);
+ }
+ }
+ #endregion
private IDockContent m_activeContent = null;
public IDockContent ActiveContent
{
@@ -107,6 +131,7 @@ public IDockContent ActiveContent
AnimateWindow(false);
}
+ var prevContent = m_activeContent;
m_activeContent = value;
SetActivePane();
if (ActivePane != null)
@@ -119,6 +144,8 @@ public IDockContent ActiveContent
DockPanel.RefreshAutoHideStrip();
SetTimerMouseTrack();
+
+ OnActiveContentChanged(EventArgs.Empty, prevContent);
}
}
View
21 WinFormsUI/Docking/DockPanel.cs
@@ -49,6 +49,7 @@ public DockPanel()
SuspendLayout();
m_autoHideWindow = new AutoHideWindowControl(this);
+ m_autoHideWindow.ActiveContentChanged += m_autoHideWindow_ActiveContentChanged;
m_autoHideWindow.Visible = false;
SetAutoHideWindowParent();
@@ -1047,6 +1048,25 @@ private bool IsClipRectsChanged(Rectangle[] clipRects)
return false;
}
+ #region Events
+ private static readonly object ActiveAutoHideContentChangedEvent = new object();
+ public event EventHandler ActiveAutoHideContentChanged
+ {
+ add { Events.AddHandler(ActiveAutoHideContentChangedEvent, value); }
+ remove { Events.RemoveHandler(ActiveAutoHideContentChangedEvent, value); }
+ }
+ protected virtual void OnActiveAutoHideContentChanged(EventArgs e)
+ {
+ EventHandler handler = (EventHandler)Events[ActiveAutoHideContentChangedEvent];
+ if (handler != null)
+ handler(this, e);
+ }
+ private void m_autoHideWindow_ActiveContentChanged(object sender, EventArgs e)
+ {
+ OnActiveAutoHideContentChanged(e);
+ }
+
+
private static readonly object ContentAddedEvent = new object();
[LocalizedCategory("Category_DockingNotification")]
[LocalizedDescription("DockPanel_ContentAdded_Description")]
@@ -1076,5 +1096,6 @@ protected virtual void OnContentRemoved(DockContentEventArgs e)
if (handler != null)
handler(this, e);
}
+ #endregion
}
}
Something went wrong with that request. Please try again.