private bool ShowPopup(PerfGraphMessage perfMessage) { lock ( _syncRoot ) { var viewModel = _userInterface.DataContext as PerfGraphViewModel; if (viewModel != null) { PerfGraphPopup popup = null; if (_notifyIcon.CustomBalloon != null && _notifyIcon.CustomBalloon.Child != null) { popup = _notifyIcon.CustomBalloon.Child as PerfGraphPopup; } var popupViewModel = new PerfGraphPopupViewModel { Message = perfMessage.Content }; popupViewModel.ShowPerfLog += popupViewModel_ShowPerfLog; if (popup != null) { PopupViewModel = popupViewModel; popup.Closed += popup_Closed; _notifyIcon.CloseBalloon( ); return(true); } var perfGraphPopup = new PerfGraphPopup { DataContext = popupViewModel }; _notifyIcon.ShowCustomBalloon(perfGraphPopup, PopupAnimation.Scroll, _popupTimeout); return(true); } } return(false); }
private void popup_Closed(object sender, EventArgs e) { var popup = sender as PerfGraphPopup; if (popup != null) { popup.Closed -= popup_Closed; } if (PopupViewModel != null) { var perfGraphPopup = new PerfGraphPopup { DataContext = PopupViewModel }; PopupViewModel = null; _notifyIcon.ShowCustomBalloon(perfGraphPopup, PopupAnimation.Scroll, _popupTimeout); } }