private async void LaboratoryDataTableRowDeleting(object sender, DataRowChangeEventArgs e) { if (this.DeleteHandled) { this.DeleteHandled = false; return; } var result = await MainWindowHelper.DeleteRowAsync ( LaboratoryBookName, LaboratoryBookPermission, e.Row ); if (result) { e.Row.AcceptChanges(); TaskBarIcon.ShowBalloonTip ( "Row action", $"Row was successfully deleted from {LaboratoryBookName} database", BalloonIcon.Info ); await MainWindowHelper.UpdateStatistics(LaboratoryBookName, User); } else { e.Row.RejectChanges(); } }
private async void LaboratoryDataTableRowChanged(object sender, DataRowChangeEventArgs e) { bool result = false; var laboratoryBookName = this.LaboratoryBookName; var laboratoryBookPermission = this.LaboratoryBookPermission; var row = e.Row; var dgLaboratoryBook = this.DgLaboratoryBook; var columnList = new List <string>(); foreach (var column in dgLaboratoryBook.Columns) { if ((string)(column.Header) == "sampleID") { continue; } var str = column.Header.ToString(); columnList.Add(str); } if (e.Action == DataRowAction.Add) { result = await Task.Run(() => { return(MainWindowHelper.AddRow(laboratoryBookName, laboratoryBookPermission, row, dgLaboratoryBook, User)); }); TaskBarIcon.ShowBalloonTip ( "Row action", $"Row was successfully added to {LaboratoryBookName} database", BalloonIcon.Info ); } if (e.Action == DataRowAction.Change) { result = await Task.Run(() => { return(MainWindowHelper.ChangeRow(laboratoryBookName, laboratoryBookPermission, row, columnList)); }); } if (result) { await MainWindowHelper.UpdateStatistics(LaboratoryBookName, User); e.Row.AcceptChanges(); } else { e.Row.RejectChanges(); } }
private async Task OnUpdaterEvent(UpdatingState ea) { switch (ea.UpdateSate) { case UpdateSate.InitializingUpdater: await this.UIThreadAsync(() => { CheckUpdatesButton.IsEnabled = false; }); break; case UpdateSate.DownloadingUpdate: await this.UIThreadAsync(() => { _TataruModel.TataruViewModel.UserStartedUpdateTextVisibility = false; _TataruModel.TataruViewModel.DownloadingUpdateVisibility = true; }); break; case UpdateSate.ReadyToRestart: await this.UIThreadAsync(() => { _TataruModel.TataruViewModel.UserStartedUpdateTextVisibility = false; _TataruModel.TataruViewModel.RestartReadyVisibility = true; _TataruModel.TataruViewModel.DownloadingUpdateVisibility = false; TaskBarIcon.ShowBalloonTip((string)this.Resources["NotifyUpdateTitle"], (string)this.Resources["NotifyUpdateText"], Hardcodet.Wpf.TaskbarNotification.BalloonIcon.Info); }); break; case UpdateSate.UpdatingFinished: await this.UIThreadAsync(() => { _TataruModel.TataruViewModel.UserStartedUpdateTextVisibility = false; if (!_TataruModel.TataruViewModel.RestartReadyVisibility && !_TataruModel.TataruViewModel.DownloadingUpdateVisibility && _TataruModel.TataruViewModel.UpdateCheckByUser ) { UserStartedUpdateText.Text = (string)this.Resources["NoUpdatesFound"]; _TataruModel.TataruViewModel.UserStartedUpdateTextVisibility = true; } _TataruModel.TataruViewModel.UpdateCheckByUser = false; OnUserStartedUpdateEnd(); }); break; } }
private void AmazonPriceChecker_Closing(object sender, System.ComponentModel.CancelEventArgs e) { //Since this method fires whenever the application begin to close, we must specifically check //if the user is meaning to exit the application so the Balloon Tip doesn't re-fire on exit try { if (CommonFunctions.UserSettings.MinimizeOnClose && !IsExiting) { CommonFunctions.Log.Debug($"Hiding application on close"); this.Visibility = Visibility.Hidden; e.Cancel = true; TaskBarIcon.ShowBalloonTip(this.Title, "App is still running in the background", BalloonIcon.Info); } else { if (DoSettingsDiffer()) { StringBuilder message = new StringBuilder(); message.AppendLine("Your settings have not been saved.\n"); message.AppendLine("Would you like to save your settings before closing?"); ConfirmationWindow shouldSaveWindow = new ConfirmationWindow("Save Settings?", message.ToString()); if (shouldSaveWindow.ShowDialog() == true) { bool shouldSave = shouldSaveWindow.Confirmed; if (shouldSave) { SaveSettings(); } //clean up tray icon TaskBarIcon.Dispose(); IsExiting = true; } else { e.Cancel = true; } } else { //clean up tray icon TaskBarIcon.Dispose(); IsExiting = true; } } } catch (Exception ex) { CommonFunctions.Log.Error("Error closing application", ex); } }
//initialize data, attach event hendlers to make datatable connected with database private async void MainWindowLoaded(object sender, RoutedEventArgs e) { if (User is Guest) { BtnModifyDatabase.Visibility = Visibility.Collapsed; BtnModifyUsers.Visibility = Visibility.Collapsed; } try { CreateTaskBarIcon(); SetUpAndStartTimer(); await SetLists(); this.DgLaboratoryBook.AutoGeneratingColumn += DgLaboratoryBookAutoGeneratingColumn; this.LaboratoryDataTable = await Task.Run(() => { return(User.GetDataFromLaboratoryBook(LaboratoryBookName, LaboratoryBookPermission)); }); this.LaboratoryDataTable.RowChanged += LaboratoryDataTableRowChanged; this.LaboratoryDataTable.RowDeleting += LaboratoryDataTableRowDeleting; this.DgLaboratoryBook.PreviewKeyDown += DgLaboratoryBookPreviewKeyDown; this.DgLaboratoryBook.CellEditEnding += DgLaboratoryBook_CellEditEnding; TaskBarIcon.ShowBalloonTip ( "Welcome", $"Succesfully connected to {LaboratoryBookName}", BalloonIcon.Info ); } catch (Exception exception) { MessageBox.Show ( exception.Message, "Initialisation error", MessageBoxButton.OK, MessageBoxImage.Error ); } }
//set up preferences for timer which send update notifications public void SetUpAndStartTimer() { _timerCheckUpdated.Interval = 3000; _timerCheckUpdated.Elapsed += async(obj, args) => { string[] result = await MainWindowHelper.CheckUpdatesAsync(LaboratoryBookName); if (_lastUpdated != DateTime.Parse(result[1]) & (User.UserName != result[0].ToString())) { TaskBarIcon.ShowBalloonTip ( "Book updates", $"Database was changed by {result[0]} ({result[1]})", BalloonIcon.Info ); } _lastUpdated = DateTime.Parse(result[1]); }; _timerCheckUpdated.Start(); }
public void ShowTaskBarPopup(string title, string message, BalloonIcon symbol) { TaskBarIcon.ShowBalloonTip(title, message, symbol); }