| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- /*************************************************************************************
- 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.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows.Threading;
- using Xceed.Wpf.AvalonDock.Layout;
- namespace Xceed.Wpf.AvalonDock.Controls
- {
- class AutoHideWindowManager
- {
- DockingManager _manager;
- internal AutoHideWindowManager(DockingManager manager)
- {
- _manager = manager;
- SetupCloseTimer();
- }
- WeakReference _currentAutohiddenAnchor = null;
- 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);
- }
- DispatcherTimer _closeTimer = null;
- 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();
- };
- }
- void StartCloseTimer()
- {
- _closeTimer.Start();
- }
- void StopCloseTimer()
- {
- _closeTimer.Stop();
- _manager.AutoHideWindow.Hide();
- _currentAutohiddenAnchor = null;
- }
- }
- }
|