public void Execute(object parameter) { // record button clicked if (parameter != null) { recordingInfo = new RecordingInfo { Name = System.IO.Path.GetRandomFileName().Replace(".", string.Empty), Location = @Properties.Settings.Default.SaveLocation, Width = viewModel.MainWindowModel.Width, Height = viewModel.MainWindowModel.Height }; // begin the countdown counter = new SettingsModel().CountdownSecond; counterCurrent = counter; notificationBalloon = Notification.Instance.ShowNotificationBalloon("Press " + new SettingsModel().HotKeyAsString + " stop process.", "Process starting...", counter * 1000 + 2000); notificationModel = (notificationBalloon.DataContext as NotificationViewModel).Model; countdownTimer = new Timer { Interval = 1000 }; countdownTimer.Elapsed += CountdownTimerEvent; countdownTimer.Start(); // Making selection click-through viewModel.MainWindowModel.Foreground = "#00000000"; viewModel.MainWindowModel.Background = "#00000000"; viewModel.MainWindowModel.RecordButton.IsVisible = false; } // contextmenu item dorecord clicked else { if (viewModel.MainWindowModel.IsRecording) { Stop(); return; } if (viewModel.MainWindowModel.SelectionVisibility == Visibility.Hidden) { viewModel.ShowSelection(); } else { viewModel.HideSelection(); } } }
public NotificationBalloon ShowNotificationBalloon(string title, string description, int timeout = 5000) { Point trayPosition = TrayInfo.GetTrayLocation(); var notificationBalloon = new NotificationBalloon {Margin = defaultMargin}; var notificationViewModel = notificationBalloon.DataContext as NotificationViewModel; notificationViewModel.Model.BalloonTitle = title; notificationViewModel.Model.BalloonContent = description; int balloons = notifictaionBalloonList.Count; if (balloons > 0) { Thickness newMargin = defaultMargin; newMargin.Bottom = (defaultMargin.Bottom * balloons) + notificationBalloon.Height * balloons + (SystemParameters.PrimaryScreenHeight - trayPosition.Y); notificationBalloon.Margin = newMargin; } tbIcon.ShowCustomBalloon(notificationBalloon, PopupAnimation.Fade, 10000000); notifictaionBalloonList.Add(new BalloonDisposable(notificationBalloon, timeout, FancyBalloonCloseCallback)); return notificationBalloon; }
public BalloonDisposable(NotificationBalloon balloon, int timeout, Action<BalloonDisposable> callback) { this.balloon = balloon; this.timeout = timeout; this.callback = callback; timer = new Timer(TimerCallback); timer.Change(timeout, Timeout.Infinite); }