All the controls missing in WPF. Over 1 million downloads.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
2.6 KiB

/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Windows.Threading;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock.Controls
{
internal class AutoHideWindowManager
{
#region Members
private DockingManager _manager;
private WeakReference _currentAutohiddenAnchor = null;
private DispatcherTimer _closeTimer = null;
#endregion
#region Constructors
internal AutoHideWindowManager( DockingManager manager )
{
_manager = manager;
this.SetupCloseTimer();
}
#endregion
#region Private Methods
public void ShowAutoHideWindow( LayoutAnchorControl anchor )
{
if( _currentAutohiddenAnchor.GetValueOrDefault<LayoutAnchorControl>() != anchor )
{
StopCloseTimer();
_currentAutohiddenAnchor = new WeakReference( anchor );
_manager.AutoHideWindow.Show( anchor );
StartCloseTimer();
}
}
public void HideAutoWindow( LayoutAnchorControl anchor = null )
{
if( anchor == null ||
anchor == _currentAutohiddenAnchor.GetValueOrDefault<LayoutAnchorControl>() )
{
StopCloseTimer();
}
else
System.Diagnostics.Debug.Assert( false );
}
private void SetupCloseTimer()
{
_closeTimer = new DispatcherTimer( DispatcherPriority.Background );
_closeTimer.Interval = TimeSpan.FromMilliseconds( 1500 );
_closeTimer.Tick += ( s, e ) =>
{
if( _manager.AutoHideWindow.IsWin32MouseOver ||
( ( LayoutAnchorable )_manager.AutoHideWindow.Model ).IsActive ||
_manager.AutoHideWindow.IsResizing )
return;
StopCloseTimer();
};
}
private void StartCloseTimer()
{
_closeTimer.Start();
}
private void StopCloseTimer()
{
_closeTimer.Stop();
_manager.AutoHideWindow.Hide();
_currentAutohiddenAnchor = null;
}
#endregion
}
}