private void itemsControl_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (CurrentViewMode == MainControls.CurrentViewMode.ArtistDetails || CurrentViewMode == MainControls.CurrentViewMode.ComposerDetails) { if (e.LeftButton == MouseButtonState.Pressed) { ListBoxItem item = VisualTreeExtensions.FindParent <ListBoxItem>(e.OriginalSource as DependencyObject); if (item != null) { TrackListItem tli = item.DataContext as TrackListItem; PersonGroup personGroup = DataBase.GetPersonGroupByName(tli.Name, false); PersonGroupWindow personGroupWindow = new PersonGroupWindow(DataBase, CurrentViewMode == MainControls.CurrentViewMode.ArtistDetails ? PersonType.Artist : PersonType.Composer, personGroup); personGroupWindow.ChangeAllSoundFiles = true; personGroupWindow.Owner = Window.GetWindow(this); personGroupWindow.ShowDialog(); UpdateTrackListItem(tli); } } } }
private void ReadValues(object[] values, TrackListItem trackListItem) { trackListItem.ID = (int)values[0]; trackListItem.Name = values[1].ToString(); trackListItem.ImageFilename = (values[2] is DBNull || values[2] == null) ? "" : values[2].ToString(); trackListItem.BirthDay = (values[3] is DBNull || values[3] == null) ? "" : values[3].ToString(); trackListItem.DayOfDeath = (values[4] is DBNull || values[4] == null) ? "" : values[4].ToString(); trackListItem.Sex = values[5] is DBNull ? SexType.Unknown : (SexType)values[5]; trackListItem.Type = values[6] is DBNull ? PersonGroupType.Unknown : (PersonGroupType)values[6]; trackListItem.Url = (values[7] is DBNull || values[7] == null) ? "" : values[7].ToString(); trackListItem.LandOfOrigin = (values[8] is DBNull || values[8] == null) ? "" : values[8].ToString(); trackListItem.Count = (int)values[9]; trackListItem.Length = (long)values[10]; trackListItem.Rating = (values[11] is DBNull) ? 0 : (int)values[11]; string timeSpan = ""; if (!string.IsNullOrEmpty(trackListItem.BirthDay)) { timeSpan += Misc.FormatDate(trackListItem.BirthDay) + " - "; } if (!String.IsNullOrEmpty(trackListItem.DayOfDeath)) { if (string.IsNullOrEmpty(timeSpan)) { timeSpan += "- "; } timeSpan += Misc.FormatDate(trackListItem.DayOfDeath); } trackListItem.TimeSpan = timeSpan; trackListItem.TypeAndSex = string.Format("{0}, {1}", DataBaseEngine.DataBase.GetNameOfPersonGroupType(trackListItem.Type), DataBaseEngine.DataBase.GetNameOfPersonGroupSex(trackListItem.Sex)); }
private void Hyperlink_Click(object sender, RoutedEventArgs e) { Hyperlink hyperlink = sender as Hyperlink; TrackListItem clickedItem = hyperlink.DataContext as TrackListItem; if (clickedItem != null) { System.Diagnostics.Process.Start(clickedItem.Url); } }
private void ChoosePictureUserControl_ImageChanged(object sender, EventArgs e) { ChoosePictureUserControl choosePictureUserControl = sender as ChoosePictureUserControl; ListBoxItem item = VisualTreeExtensions.FindParent <ListBoxItem>(choosePictureUserControl as DependencyObject); if (item != null) { TrackListItem selItem = item.DataContext as TrackListItem; selItem.ImageFilename = choosePictureUserControl.ImageFilename; } }
void UpdateTrackListItem(TrackListItem item) { string sql = GetSql(item.ID); using (DataBaseView view = DataBaseView.Create(this.DataBase, sql)) { object[] values; values = view.Read(); if (values != null) { ReadValues(values, item); } } }
private bool FilterRow(object row) { if (string.IsNullOrEmpty(FullTextSearch)) { return(true); } string filterString = FullTextSearch.ToLower(); bool found = false; TrackListItem trackListItem = row as TrackListItem; if (CatalogView.CompareString(trackListItem.Title, filterString)) { found = true; } return(found); }
private void OpenSelectedPersonGroup() { TrackListItem tli = dataGrid.SelectedItem as TrackListItem; if (tli == null) { return; } PersonGroup personGroup = DataBase.GetPersonGroupByName(tli.Title, false); PersonGroupWindow personGroupWindow = new PersonGroupWindow(DataBase, CurrentViewMode == MainControls.CurrentViewMode.ArtistTable ? PersonType.Artist : PersonType.Composer, personGroup); personGroupWindow.ChangeAllSoundFiles = true; personGroupWindow.Owner = Window.GetWindow(this); if (personGroupWindow.ShowDialog() == true) { tli.Title = personGroup.Name; } }
void bwTrackList_DoWork(object sender, DoWorkEventArgs e) { string sql = ""; Big3.Hitbase.DataBaseEngine.Condition searchCondition = Big3.Hitbase.DataBaseEngine.Condition.Combine(Condition, ConditionFromTree); switch (CurrentViewMode) { case MainControls.CurrentViewMode.ArtistTable: sql = "SELECT PersonGroup.Name, COUNT(*) AS TotalCount, SUM(Cast(Track.Length as bigint)) AS TotalLength " + "FROM Track INNER JOIN " + "PersonGroup ON Track.ArtistID = PersonGroup.PersonGroupID " + "GROUP BY PersonGroup.Name, PersonGroup.SaveAs"; if (searchCondition != null && searchCondition.Count > 0) { if (searchCondition[0].Value.ToString() == "?") { sql += " HAVING PersonGroup.SaveAs < 'A' OR PersonGroup.SaveAs > 'ZZZZZ'"; } else { sql += " HAVING PersonGroup.SaveAs >= '" + searchCondition[0].Value + "' AND PersonGroup.SaveAs < '" + searchCondition[0].Value + "ZZZZZ'"; } } sql += " ORDER BY PersonGroup.SaveAs"; break; case MainControls.CurrentViewMode.ComposerTable: sql = "SELECT PersonGroup.Name, COUNT(*) AS TotalCount, SUM(Cast(Track.Length as bigint)) AS TotalLength " + "FROM Track INNER JOIN " + "PersonGroup ON Track.ComposerID = PersonGroup.PersonGroupID " + "GROUP BY PersonGroup.Name, PersonGroup.SaveAs "; if (searchCondition != null && searchCondition.Count > 0) { if (searchCondition[0].Value.ToString() == "?") { sql += " HAVING PersonGroup.SaveAs < 'A' OR PersonGroup.SaveAs > 'ZZZZZ'"; } else { sql += " HAVING PersonGroup.SaveAs >= '" + searchCondition[0].Value + "' AND PersonGroup.SaveAs < '" + searchCondition[0].Value + "ZZZZZ'"; } } sql += " ORDER BY PersonGroup.SaveAs"; break; case MainControls.CurrentViewMode.GenreTable: sql = "SELECT Category.Name, COUNT(*) AS TotalCount, SUM(Cast(Track.Length as bigint)) AS TotalLength " + "FROM Track LEFT JOIN " + "CD ON Track.CDID = CD.CDID LEFT JOIN " + "Category ON Track.CategoryID = Category.CategoryID OR CD.CategoryID = Category.CategoryID " + "GROUP BY Category.Name"; if (searchCondition != null && searchCondition.Count > 0) { sql += " HAVING Category.Name LIKE '" + searchCondition[0].Value + "%'"; } break; case MainControls.CurrentViewMode.MediumTable: sql = "SELECT Medium.Name, COUNT(*) AS TotalCount, SUM(Cast(Track.Length as bigint)) AS TotalLength " + "FROM Track INNER JOIN " + "CD ON Track.CDID = CD.CDID LEFT JOIN " + "Medium ON CD.MediumID = Medium.MediumID " + "GROUP BY Medium.Name"; if (searchCondition != null && searchCondition.Count > 0) { sql += " HAVING Medium.Name LIKE '" + searchCondition[0].Value + "%'"; } break; case MainControls.CurrentViewMode.YearTable: sql = "SELECT Track.YearRecorded, COUNT(*) AS TotalCount, SUM(CAST(Track.Length as bigint)) AS TotalLength " + "FROM Track " + "GROUP BY Track.YearRecorded"; if (searchCondition != null && searchCondition.Count > 0) { if (searchCondition.Count > 1) { sql += " HAVING Track.YearRecorded >= " + searchCondition[0].Value + " AND Track.YearRecorded < " + searchCondition[1].Value; } else { sql += " HAVING Track.YearRecorded=" + searchCondition[0].Value + ""; } } break; case MainControls.CurrentViewMode.RatingTable: sql = "SELECT Track.Rating, COUNT(*) AS TotalCount, SUM(CAST(Track.Length as bigint)) AS TotalLength " + "FROM Track " + "GROUP BY Track.Rating"; if (searchCondition != null && searchCondition.Count > 0 && searchCondition[0].Value != null) { sql += " HAVING Track.Rating = " + searchCondition[0].Value + ""; } break; } SafeObservableCollection <TrackListItem> items = new SafeObservableCollection <TrackListItem>(); Dictionary <string, TrackListItem> dictItems = new Dictionary <string, TrackListItem>(); // Für schnelleren Zugriff using (DataBaseView view = DataBaseView.Create(this.DataBase, sql)) { object[] values; while ((values = view.Read()) != null) { TrackListItem trackListItem = new TrackListItem(); trackListItem.Title = values[0].ToString(); if (CurrentViewMode == MainControls.CurrentViewMode.YearTable && trackListItem.Title == "0") { trackListItem.Title = StringTable.Undefined; } trackListItem.Count = (int)values[1]; trackListItem.Length = (long)values[2]; trackListItem.Rating = 0; dictItems.Add(trackListItem.Title, trackListItem); items.AddItemFromThread(trackListItem); } } // Rating ermitteln sql = ""; switch (CurrentViewMode) { case MainControls.CurrentViewMode.ArtistTable: { sql = "SELECT PersonGroup.Name, AVG(CAST(Track.Rating AS decimal)) AS Expr3, PersonGroup.SaveAs " + "FROM Track INNER JOIN " + "PersonGroup ON Track.ArtistID = PersonGroup.PersonGroupID " + "WHERE (Track.Rating > 0) " + "GROUP BY PersonGroup.Name, PersonGroup.SaveAs"; break; } case MainControls.CurrentViewMode.ComposerTable: { sql = "SELECT PersonGroup.Name, AVG(CAST(Track.Rating AS decimal)) AS Expr3 " + "FROM Track INNER JOIN " + "PersonGroup ON Track.ComposerID = PersonGroup.PersonGroupID " + "WHERE (Track.Rating > 0) " + "GROUP BY PersonGroup.Name"; break; } case MainControls.CurrentViewMode.GenreTable: { sql = "SELECT category.Name, AVG(CAST(Track.Rating AS decimal)) AS Expr3 " + "FROM Track LEFT JOIN " + "CD ON Track.CDID = CD.CDID LEFT JOIN " + "Category AS Category ON Track.CategoryID = Category.CategoryID OR CD.CategoryID = Category.CategoryID " + "WHERE (Track.Rating > 0) " + "GROUP BY Category.Name"; break; } case MainControls.CurrentViewMode.YearTable: { sql = "SELECT Track.YearRecorded, AVG(CAST(Track.Rating AS decimal)) AS Expr3 " + "FROM Track " + "WHERE (Track.Rating > 0) " + "GROUP BY Track.YearRecorded"; break; } } if (sql != "") { using (DataBaseView view = DataBaseView.Create(this.DataBase, sql)) { object[] values; while ((values = view.Read()) != null) { string key = values[0].ToString(); if (CurrentViewMode == MainControls.CurrentViewMode.YearTable && key == "0") { key = StringTable.Undefined; } if (dictItems.ContainsKey(key)) { TrackListItem trackListItem = dictItems[key]; trackListItem.Rating = (double)(decimal)values[1]; } } } } e.Result = items; }
private void dataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { DataGridRow row = VisualTreeExtensions.FindParent <DataGridRow>(e.OriginalSource as DependencyObject); if (row == null) { return; } switch (CurrentViewMode) { case MainControls.CurrentViewMode.ArtistTable: case MainControls.CurrentViewMode.ComposerTable: { OpenSelectedPersonGroup(); break; } case MainControls.CurrentViewMode.YearTable: { TrackListItem tli = dataGrid.SelectedItem as TrackListItem; int year = Misc.Atoi(tli.Title); AddViewCommandParameters addViewParams = new AddViewCommandParameters(); addViewParams.Condition = new DataBaseEngine.Condition(); addViewParams.Condition.Add(new SingleCondition() { Field = Field.TrackYearRecorded, Operator = Operator.Equal, Value = year, Logical = Logical.Or }); addViewParams.Condition.Add(new SingleCondition() { Field = Field.YearRecorded, Operator = Operator.Equal, Value = year }); addViewParams.ImageResourceString = "Calendar.png"; addViewParams.Title = tli.Title; addViewParams.ViewMode = MainControls.CurrentViewMode.MyMusicDetails; CatalogViewCommands.AddView.Execute(addViewParams, Application.Current.MainWindow); e.Handled = true; break; } case MainControls.CurrentViewMode.RatingTable: { TrackListItem tli = dataGrid.SelectedItem as TrackListItem; int rating = Misc.Atoi(tli.Title); AddViewCommandParameters addViewParams = new AddViewCommandParameters(); addViewParams.Condition = new DataBaseEngine.Condition(); addViewParams.Condition.Add(new SingleCondition() { Field = Field.TrackRating, Operator = Operator.Equal, Value = rating }); addViewParams.ImageResourceString = "Star.png"; addViewParams.Title = tli.Title; addViewParams.ViewMode = MainControls.CurrentViewMode.MyMusicDetails; CatalogViewCommands.AddView.Execute(addViewParams, Application.Current.MainWindow); e.Handled = true; break; } case MainControls.CurrentViewMode.GenreTable: { TrackListItem tli = dataGrid.SelectedItem as TrackListItem; string genre = tli.Title; AddViewCommandParameters addViewParams = new AddViewCommandParameters(); addViewParams.Condition = new DataBaseEngine.Condition(); addViewParams.Condition.Add(new SingleCondition(Field.Category, Operator.Equal, genre, Logical.Or)); addViewParams.Condition.Add(new SingleCondition(Field.TrackCategory, Operator.Equal, genre)); addViewParams.ImageResourceString = "Category.png"; addViewParams.Title = tli.Title; addViewParams.ViewMode = MainControls.CurrentViewMode.MyMusicDetails; CatalogViewCommands.AddView.Execute(addViewParams, Application.Current.MainWindow); e.Handled = true; break; } } } }
void bwTrackList_DoWork(object sender, DoWorkEventArgs e) { string sql = ""; switch (CurrentViewMode) { case MainControls.CurrentViewMode.ArtistDetails: case MainControls.CurrentViewMode.ComposerDetails: sql = GetArtistDetailsSql(); if (Condition != null && Condition.Count > 0 && Condition[0].Value != null) { sql += " HAVING PersonGroup.Name LIKE '" + Condition[0].Value + "%'"; } break; //case MainControls.CurrentViewMode.ComposerTable: // sql = "SELECT PersonGroup.Name, COUNT(*) AS TotalCount, SUM(Cast(Track.Length as bigint)) AS TotalLength " + // "FROM Track INNER JOIN " + // "PersonGroup ON Track.ComposerID = PersonGroup.PersonGroupID " + // "GROUP BY PersonGroup.Name"; // if (Condition != null && Condition.Count > 0) // { // sql += " HAVING PersonGroup.Name LIKE '" + Condition[0].Value + "%'"; // } // break; //case MainControls.CurrentViewMode.GenreTable: // sql = "SELECT Category.Name, COUNT(*) AS TotalCount, SUM(Cast(Track.Length as bigint)) AS TotalLength " + // "FROM Track INNER JOIN " + // "Category ON Track.CategoryID = Category.CategoryID " + // "GROUP BY Category.Name"; // if (Condition != null && Condition.Count > 0) // { // sql += " HAVING Category.Name LIKE '" + Condition[0].Value + "%'"; // } // break; //case MainControls.CurrentViewMode.YearTable: // sql = "SELECT Track.YearRecorded, COUNT(*) AS TotalCount, SUM(CAST(Track.Length as bigint)) AS TotalLength " + // "FROM Track " + // "GROUP BY Track.YearRecorded"; // break; //case MainControls.CurrentViewMode.RatingTable: // sql = "SELECT Track.Rating, COUNT(*) AS TotalCount, SUM(CAST(Track.Length as bigint)) AS TotalLength " + // "FROM Track " + // "GROUP BY Track.Rating"; // if (Condition != null && Condition.Count > 0) // { // sql += " HAVING Track.Rating = " + Condition[0].Value + ""; // } // break; } SafeObservableCollection <TrackListItem> items = new SafeObservableCollection <TrackListItem>(); using (DataBaseView view = DataBaseView.Create(this.DataBase, sql)) { object[] values; while ((values = view.Read()) != null) { TrackListItem trackListItem = new TrackListItem(); ReadValues(values, trackListItem); items.AddItemFromThread(trackListItem); } } e.Result = items; }