private void LoadHUD(HudDragCanvas dgCanvas, ReplayerViewModel viewModel, HudLayoutInfoV2 activeLayout) { var seats = (int)CurrentCapacity; var hudPanelService = ServiceLocator.Current.GetInstance <IHudPanelService>(ReplayerPokerSite.ToString()); var nonToolLayoutStats = activeLayout .HudPlayerTypes .SelectMany(x => x.Stats) .Select(x => x.Stat) .Concat(activeLayout .HudBumperStickerTypes .SelectMany(x => x.Stats) .Select(x => x.Stat)) .Concat(new[] { Stat.TotalHands }) .Distinct() .ToArray(); var hudElements = new List <HudElementViewModel>(); var hudElementCreator = ServiceLocator.Current.GetInstance <IHudElementViewModelCreator>(); var hudElementCreationInfo = new HudElementViewModelCreationInfo { GameType = EnumGameType.CashHoldem, HudLayoutInfo = activeLayout, PokerSite = ReplayerPokerSite }; for (var i = 0; i < seats; i++) { var replayerPlayer = viewModel.PlayersCollection[i]; hudElementCreationInfo.SeatNumber = i + 1; if ((int)activeLayout.TableType < hudElementCreationInfo.SeatNumber) { continue; } var hudElement = hudElementCreator.Create(hudElementCreationInfo); if (string.IsNullOrEmpty(replayerPlayer.Name)) { if (hudElement != null) { EmptySeats.Add(hudElement); } continue; } var player = dataService.GetPlayer(replayerPlayer.Name, viewModel.CurrentHand.PokersiteId); if (player == null) { if (hudElement != null) { EmptySeats.Add(hudElement); } continue; } if (hudElement == null || !playerIndicators.TryGetValue(replayerPlayer.Name, out HudIndicators playerData)) { continue; } hudElement.PlayerId = player.PlayerId; hudElement.PlayerName = replayerPlayer.Name; hudElement.TotalHands = playerData.TotalHands; var playerNotes = dataService.GetPlayerNotes(player.PlayerId); hudElement.NoteToolTip = NoteBuilder.BuildNote(playerNotes); hudElement.IsXRayNoteVisible = playerNotes.Any(x => x.IsAutoNote); var graphTools = hudElement.Tools.OfType <HudGraphViewModel>().ToArray(); foreach (var graphTool in graphTools) { graphTool.StatSessionCollection = new ReactiveList <decimal>(); } var heatMapTools = hudElement.Tools.OfType <HudHeatMapViewModel>() .Concat(hudElement.Tools.OfType <HudGaugeIndicatorViewModel>() .SelectMany(x => x.GroupedStats) .SelectMany(x => x.Stats) .Where(x => x.HeatMapViewModel != null) .Select(x => x.HeatMapViewModel)) .ToArray(); heatMapTools.ForEach(x => { var heatMapKey = playerData.HeatMaps.Keys .ToArray() .FirstOrDefault(p => p.Stat == x.BaseStat.Stat); if (heatMapKey != null) { x.HeatMap = playerData.HeatMaps[heatMapKey]; } }); var gaugeIndicatorTools = hudElement.Tools.OfType <HudGaugeIndicatorViewModel>().ToArray(); hudElement.SessionMoneyWonCollection = new ObservableCollection <decimal>(); var activeLayoutHudStats = hudElement.ToolsStatInfoCollection .Concat(heatMapTools.Select(x => x.BaseStat)) .Concat(gaugeIndicatorTools.Select(x => x.BaseStat)) .ToList(); var extraStats = (from nonToolLayoutStat in nonToolLayoutStats join activateLayoutHudStat in activeLayoutHudStats on nonToolLayoutStat equals activateLayoutHudStat.Stat into grouped from extraStat in grouped.DefaultIfEmpty() where extraStat == null select new StatInfo { Stat = nonToolLayoutStat }).ToArray(); activeLayoutHudStats.AddRange(extraStats); StatsProvider.UpdateStats(activeLayoutHudStats); foreach (var statInfo in activeLayoutHudStats) { var propertyName = StatsProvider.GetStatProperyName(statInfo.Stat); if (!string.IsNullOrEmpty(propertyName)) { if (playerData.TotalHands < statInfo.MinSample) { statInfo.IsNotVisible = true; } statInfo.AssignStatInfoValues(playerData, propertyName); } else if (!(statInfo is StatInfoBreak) && statInfo.Stat != Stat.PlayerInfoIcon) { continue; } } hudElement.StatInfoCollection = activeLayoutHudStats; var isNoteIconSet = false; foreach (var toolViewModel in hudElement.Tools.Where(x => x is IHudNonPopupToolViewModel).ToArray()) { if (!isNoteIconSet && toolViewModel is HudPlainStatBoxViewModel && !(toolViewModel is HudFourStatsBoxViewModel)) { (toolViewModel as HudPlainStatBoxViewModel).IsNoteIconEnabled = true; isNoteIconSet = true; } var panel = hudPanelService.Create(toolViewModel); if (panel != null) { dgCanvas.Children.Add(panel); Canvas.SetLeft(panel, toolViewModel.Position.X); Canvas.SetTop(panel, toolViewModel.Position.Y); } } hudElements.Add(hudElement); } hudLayoutsService.SetPlayerTypeIcon(hudElements, activeLayout); }