private void HandleClose(bool hideOnly) { TimeSpan elapsed = DateTime.Now - _lastShowTime; if (elapsed >= DelayInterval) { // if the dialog has been shown for more than 500ms, just close it if (_currentWindow != null && _currentWindow.IsVisible) { if (hideOnly) { _currentWindow.Hide(); } else { _currentWindow.ForceClose(); } } } else { CloseTimer.Tag = hideOnly; // otherwise, set a timer so that we close it after it has been shown for 500ms CloseTimer.Interval = DelayInterval - elapsed; CloseTimer.Start(); } }
public bool Close() { if (IsOpen) { _currentWindow.ForceClose(); _currentWindow = null; return(true); } else { return(false); } }