private void ShowLast20PlayerItemsUsed()
 {
     var title = "UNKNOWN";
     var source = new List<ItemUsedHistoryItem>();
     dynamic players = null;
     dynamic player = null;
     if (IsHistory)
     {
         players = ((HistoryGroup) Instance.PlayerInfoSource).Children;
     }
     if (IsCurrent)
     {
         players = ((StatGroup) Instance.PlayerInfoSource).Children;
     }
     if (IsHistory)
     {
         player = ((List<HistoryGroup>) players).Where(p => p != null)
                                                .Where(p => String.Equals(p.Name, MainView.View.SelectedPlayerName.Text.ToString(CultureInfo.InvariantCulture), Constants.InvariantComparer))
                                                .Cast<HistoryGroup>()
                                                .FirstOrDefault();
         if (player == null)
         {
             return;
         }
         title = player.Name;
     }
     if (IsCurrent)
     {
         player = ((List<StatGroup>) players).Where(p => p != null)
                                             .Where(p => String.Equals(p.Name, MainView.View.SelectedPlayerName.Text.ToString(CultureInfo.InvariantCulture), Constants.InvariantComparer))
                                             .Cast<Player>()
                                             .FirstOrDefault();
         if (player == null)
         {
             return;
         }
         title = player.Name;
     }
     foreach (var item in player.Last20Items)
     {
         source.Add(new ItemUsedHistoryItem
         {
             Item = Regex.Replace(item.Line.Action, @"\[Hq\]", "[HQ]", SharedRegEx.DefaultOptions),
             TimeStamp = item.TimeStamp
         });
     }
     if (!source.Any())
     {
         return;
     }
     var x = new xMetroWindowDataGrid
     {
         Title = title,
         xMetroWindowDG =
         {
             ItemsSource = source
         }
     };
     x.Show();
 }
 private void ShowLast20MonsterActions(string actionType)
 {
     var title = "UNKNOWN";
     var source = new List<ActionHistoryItem>();
     dynamic monsters = null;
     dynamic monster = null;
     if (IsHistory)
     {
         monsters = ((HistoryGroup) Instance.MonsterInfoSource).Children;
     }
     if (IsCurrent)
     {
         monsters = ((StatGroup) Instance.MonsterInfoSource).Children;
     }
     if (IsHistory)
     {
         monster = ((List<HistoryGroup>) monsters).Where(p => p != null)
                                                  .Where(p => String.Equals(p.Name, MainView.View.SelectedMonsterName.Text.ToString(CultureInfo.InvariantCulture), Constants.InvariantComparer))
                                                  .Cast<HistoryGroup>()
                                                  .FirstOrDefault();
         if (monster == null)
         {
             return;
         }
         title = monster.Name;
     }
     if (IsCurrent)
     {
         monster = ((List<StatGroup>) monsters).Where(p => p != null)
                                               .Where(p => String.Equals(p.Name, MainView.View.SelectedMonsterName.Text.ToString(CultureInfo.InvariantCulture), Constants.InvariantComparer))
                                               .Cast<Monster>()
                                               .FirstOrDefault();
         if (monster == null)
         {
             return;
         }
         title = monster.Name;
     }
     switch (actionType)
     {
         case "Damage":
             foreach (var action in monster.Last20DamageActions)
             {
                 source.Add(new ActionHistoryItem
                 {
                     Action = action.Line.Action,
                     Amount = action.Line.Amount,
                     Critical = action.Line.Crit.ToString(),
                     Source = action.Line.Source,
                     Target = action.Line.Target,
                     TimeStamp = action.TimeStamp
                 });
             }
             break;
         case "DamageTaken":
             foreach (var action in monster.Last20DamageTakenActions)
             {
                 source.Add(new ActionHistoryItem
                 {
                     Action = action.Line.Action,
                     Amount = action.Line.Amount,
                     Critical = action.Line.Crit.ToString(),
                     Source = action.Line.Source,
                     Target = action.Line.Target,
                     TimeStamp = action.TimeStamp
                 });
             }
             break;
         case "Healing":
             foreach (var action in monster.Last20HealingActions)
             {
                 source.Add(new ActionHistoryItem
                 {
                     Action = action.Line.Action,
                     Amount = action.Line.Amount,
                     Critical = action.Line.Crit.ToString(),
                     Source = action.Line.Source,
                     Target = action.Line.Target,
                     TimeStamp = action.TimeStamp
                 });
             }
             break;
     }
     if (!source.Any())
     {
         return;
     }
     var x = new xMetroWindowDataGrid
     {
         Title = title,
         xMetroWindowDG =
         {
             ItemsSource = source
         }
     };
     x.Show();
 }