private void ButtonShowDetails_Click(object sender, RoutedEventArgs e) { DataGridRow row = VisualTreeExtensions.FindParent <DataGridRow>(sender as DependencyObject); if (row != null) { StatisticsItem item = row.DataContext as StatisticsItem; Big3.Hitbase.DataBaseEngine.Condition condition = new DataBaseEngine.Condition(); string image = ""; string title = ""; CurrentViewMode viewMode = CurrentViewMode.None; if (item.ShowDetails) { switch (item.StatisticOverviewType) { case StatisticOverviewType.TrackLengthLongest: case StatisticOverviewType.TrackLengthShortest: { condition.Add(new SingleCondition(Field.TrackLength, Operator.Equal, item.RawValue)); title = item.Name; viewMode = CurrentViewMode.MyMusicTable; image = "Music.png"; break; } case StatisticOverviewType.CDTrackMax: { condition.Add(new SingleCondition(Field.NumberOfTracks, Operator.Equal, item.RawValue)); title = item.Name; viewMode = CurrentViewMode.AlbumTable; image = "Music.png"; break; } case StatisticOverviewType.CDLengthLongest: case StatisticOverviewType.CDLengthShortest: { condition.Add(new SingleCondition(Field.TotalLength, Operator.Equal, item.RawValue)); title = item.Name; viewMode = CurrentViewMode.AlbumTable; image = "Music.png"; break; } case StatisticOverviewType.CDAssignedCount: { condition.Add(new SingleCondition(Field.Identity, Operator.NotEmpty, null)); title = item.Name; viewMode = CurrentViewMode.AlbumTable; image = "Music.png"; break; } case StatisticOverviewType.CDAssignedNotCount: { condition.Add(new SingleCondition(Field.Identity, Operator.Empty, null)); title = item.Name; viewMode = CurrentViewMode.AlbumTable; image = "Music.png"; break; } default: break; } AddViewCommandParameters addViewParams = new AddViewCommandParameters(); addViewParams.Condition = condition; addViewParams.ImageResourceString = image; addViewParams.Title = title; addViewParams.ViewMode = viewMode; CatalogViewCommands.AddView.Execute(addViewParams, Application.Current.MainWindow); } } }
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; } } } }