private void AddOverviewStatistic(StatisticOverviewType statisticOverviewType)
        {
            StatisticsItem statItem = new StatisticsItem();

            statItem.StatisticOverviewType = statisticOverviewType;
            statisticList.Add(statItem);

            BackgroundWorker bw = new BackgroundWorker();

            bw.DoWork += delegate(object sender, DoWorkEventArgs e)
            {
                switch (statisticOverviewType)
                {
                case StatisticOverviewType.TrackLengthSum:
                {
                    statItem.Name = StringTable.TEXT_STATISTICS1;
                    Int64 value = StatisticTrackLengthSum();
                    e.Result = Misc.GetTextFromSeconds((int)(value / 1000), false);
                    break;
                }

                case StatisticOverviewType.TrackCount:
                {
                    statItem.Name = StringTable.TEXT_STATISTICS2;
                    Int32 value = StatisticTrackCount();
                    e.Result = value.ToString();
                    break;
                }

                case StatisticOverviewType.TrackLengthLongest:
                {
                    statItem.Name        = StringTable.TEXT_STATISTICS3;
                    statItem.ShowDetails = true;
                    Int32 value = StatisticTrackLongest();
                    e.Result          = Misc.GetShortTimeString(value);
                    statItem.RawValue = value;
                    break;
                }

                case StatisticOverviewType.TrackLengthShortest:
                {
                    statItem.Name        = StringTable.TEXT_STATISTICS4;
                    statItem.ShowDetails = true;
                    Int32 value = StatisticTrackShortest();
                    statItem.RawValue = value;
                    e.Result          = Misc.GetShortTimeString(value);
                    break;
                }

                case StatisticOverviewType.TrackLengthAverage:
                {
                    statItem.Name = StringTable.TEXT_STATISTICS5;
                    Int64 value = StatisticTrackAverage();
                    e.Result = Misc.GetShortTimeString(value);
                    break;
                }

                case StatisticOverviewType.TrackCountCDAverage:
                {
                    statItem.Name = StringTable.TEXT_STATISTICS6;
                    double value = StatisticTrackCountCDAverage();
                    e.Result = string.Format("{0:0.##}", value);
                    break;
                }

                case StatisticOverviewType.CDCount:
                {
                    statItem.Name = StringTable.TEXT_STATISTICS7;
                    int value = StatisticCDsCount();
                    e.Result = value.ToString();
                    break;
                }

                case StatisticOverviewType.CDSamplerCount:
                {
                    statItem.Name = StringTable.TEXT_STATISTICS8;
                    int value = StatisticCDSamplerCount();
                    e.Result = value.ToString();
                    break;
                }

                case StatisticOverviewType.CDTrackMax:
                {
                    statItem.Name        = StringTable.TEXT_STATISTICS9;
                    statItem.ShowDetails = true;
                    int value = StatisticCDTrackMax();
                    statItem.RawValue = value;
                    e.Result          = value.ToString();
                    break;
                }

                case StatisticOverviewType.CDLengthShortest:
                {
                    statItem.Name        = StringTable.TEXT_STATISTICS12;
                    statItem.ShowDetails = true;
                    int value = StatisticCDLengthShortest();
                    statItem.RawValue = value;
                    e.Result          = Misc.GetShortTimeString(value);
                    break;
                }

                case StatisticOverviewType.CDLengthLongest:
                {
                    statItem.Name        = StringTable.TEXT_STATISTICS11;
                    statItem.ShowDetails = true;
                    int value = StatisticCDLengthLongest();
                    statItem.RawValue = value;
                    e.Result          = Misc.GetShortTimeString(value);
                    break;
                }

                case StatisticOverviewType.CDLengthAverage:
                {
                    statItem.Name = StringTable.TEXT_STATISTICS10;
                    long value = StatisticCDLengthAverage();
                    e.Result = Misc.GetShortTimeString(value);
                    break;
                }

                case StatisticOverviewType.ArtistCount:
                {
                    statItem.Name = StringTable.TEXT_STATISTICS13;
                    int value = StatisticArtistCount();
                    e.Result = value.ToString();
                    break;
                }

                case StatisticOverviewType.CDSetsCount:
                {
                    statItem.Name = StringTable.TEXT_STATISTICS14;
                    int value = StatisticCDSetsCount();
                    e.Result = value.ToString();
                    break;
                }

                case StatisticOverviewType.CDAssignedNotCount:
                {
                    statItem.Name        = StringTable.TEXT_STATISTICS15;
                    statItem.ShowDetails = true;
                    int value = StatisticCDAssignedNotCount();
                    statItem.RawValue = value;
                    e.Result          = value.ToString();
                    break;
                }

                case StatisticOverviewType.CDAssignedCount:
                {
                    statItem.Name        = StringTable.TEXT_STATISTICS16;
                    statItem.ShowDetails = true;
                    int value = StatisticCDAssignedCount();
                    statItem.RawValue = value;
                    e.Result          = value.ToString();
                    break;
                }

                case StatisticOverviewType.CDLoanedCount:
                {
                    statItem.Name = StringTable.TEXT_STATISTICS17;
                    int value = StatisticCDLoanedCount();
                    e.Result = value.ToString();
                    break;
                }

                case StatisticOverviewType.CDTotalValue:
                {
                    statItem.Name = StringTable.TEXT_STATISTICS18;
                    long value = StatisticCDTotalValue();
                    e.Result = Misc.FormatCurrencyValue((int)value);
                    break;
                }
                }
            };
            bw.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e)
            {
                statItem.Value = (string)e.Result;
            };
            bw.RunWorkerAsync();
        }
        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);
                }
            }
        }