private void OpenNote_Click(object sender, RoutedEventArgs e) { OracleDbContext db = new OracleDbContext(); int UserId = CurrentUser.User.UserId; var currentSong = (SongsUser)((Button)sender).Tag; var song = db.Songs.FirstOrDefault(x => x.SongsId == currentSong.SongId_SongsUser); OneSong.songID = song.SongsId; SongsPage.musicID = song.SongsId; var currentPage = ((MainWindow)Application.Current.MainWindow).CurrentPage.Content; if (currentPage == null || (currentPage != null && currentPage.GetType().Name == "UserPage")) { OneSong one = new OneSong(); one.Name.Text = song.Name; one.Author.Text = song.Author; one.Text.Text = song.Text; one.ChordsComboBox.Visibility = Visibility.Collapsed; if (song.Music != null) { one.Music.Visibility = Visibility.Visible; } else { one.Music.Visibility = Visibility.Collapsed; } if (song.Image != null) { one.Source.Source = Pima.ViewModel.Converter.ConvertByteArrayToImage(song.Image); } else { one.Source.Visibility = Visibility.Collapsed; } if (song.Description != null) { one.Description.Text = song.Description; } else { one.Description.Visibility = Visibility.Collapsed; } (currentPage as UserPages.UserPage).CurrentPage.Navigate(one); } }
private void GridResult_PreviewMouseDown(object sender, MouseButtonEventArgs e) { if (ArticleButton.IsChecked == true) { var currentArticle = (Model.Article)((Grid)sender).Tag; int? id = currentArticle.ArticleId; OneArticle one = new OneArticle(); OneArticle.articleId = (int)id; one.Title.Text = currentArticle.Title; one.Text.Text = currentArticle.Text; if (currentArticle.Image != null) { one.Source.Source = Pima.ViewModel.Converter.ConvertByteArrayToImage(currentArticle.Image); } else { one.Source.Visibility = Visibility.Collapsed; } CurrentPage.Navigate(one); } else if (NoteButton.IsChecked == true) { var currentArticle = (Model.Notes)((Grid)sender).Tag; int? id = currentArticle.NotesId; OneNote one = new OneNote(); OneNote.articleId = (int)id; one.Name.Text = currentArticle.Name; //one.Text.Text = currentArticle.Text; if (currentArticle.Note != null) { one.Source.Source = Pima.ViewModel.Converter.ConvertByteArrayToImage(currentArticle.Note); } else { one.Source.Visibility = Visibility.Collapsed; } CurrentPage.Navigate(one); } else if (SongButton.IsChecked == true) { var currentSong = (Model.Songs)((Grid)sender).Tag; int? id = currentSong.SongsId; OneSong one = new OneSong(); OneSong.songID = (int)id; one.Name.Text = currentSong.Name; //one.Text.Text = currentArticle.Text; if (currentSong.Image != null) { one.Source.Source = Pima.ViewModel.Converter.ConvertByteArrayToImage(currentSong.Image); } else { one.Source.Visibility = Visibility.Collapsed; } CurrentPage.Navigate(one); } else if (ChordButton.IsChecked == true) { var currentChord = (Model.Chords)((Grid)sender).Tag; int? id = currentChord.ChordsId; OneChord one = new OneChord(); OneChord.ChordId = (int)id; one.Name.Text = currentChord.Name; //one.Text.Text = currentArticle.Text; if (currentChord.Chord != null) { one.Source.Source = Pima.ViewModel.Converter.ConvertByteArrayToImage(currentChord.Chord); } else { one.Source.Visibility = Visibility.Collapsed; } CurrentPage.Navigate(one); } }