コード例 #1
0
        private HudLayoutInfoV2 ConvertLayout(HudLayoutInfo layout)
        {
            var result = new HudLayoutInfoV2
            {
                Name                  = layout.Name,
                IsDefault             = layout.IsDefault,
                Opacity               = layout.HudOpacity,
                TableType             = layout.TableType,
                HudBumperStickerTypes = layout.HudBumperStickerTypes,
                HudPlayerTypes        = layout.HudPlayerTypes,
                LayoutTools           = new List <HudLayoutTool>
                {
                    new HudLayoutPlainBoxTool
                    {
                        Stats       = new ReactiveList <StatInfo>(layout.HudStats),
                        Positions   = layout.HudPositionsInfo,
                        UIPositions = layout.UiPositionsInfo.Select(x =>
                                                                    new HudPositionInfo
                        {
                            Position = x.Position,
                            Seat     = x.Seat
                        }).ToList()
                    }
                }
            };

            return(result);
        }
コード例 #2
0
        private void DuplicateAdditionalLayouts(TableType[] tableTypes, HudLayoutInfoV2 sourceLayout, IHudLayoutsService hudLayoutsService)
        {
            LogProvider.Log.Info($"Duplicate layout for the following types: {string.Join(", ", tableTypes.Select(x => x.Name))}");

            foreach (var tableType in tableTypes)
            {
                if (!Enum.IsDefined(typeof(EnumTableType), (byte)tableType.MaxPlayers))
                {
                    continue;
                }

                var duplicateTableType = (EnumTableType)tableType.MaxPlayers;

                var sourceTableTypeText    = CommonResourceManager.Instance.GetEnumResource(sourceLayout.TableType);
                var duplicateTableTypeText = CommonResourceManager.Instance.GetEnumResource(duplicateTableType);

                var duplicateLayoutName = $"{sourceLayout.Name.Replace(sourceTableTypeText, string.Empty)} {duplicateTableTypeText}";

                var duplicatedLayout = hudLayoutsService.DuplicateLayout(duplicateTableType, duplicateLayoutName, sourceLayout);

                if (duplicatedLayout != null)
                {
                    LogProvider.Log.Info($"Duplicated {sourceLayout.Name}, {sourceTableTypeText} to {duplicatedLayout.Name}, {duplicateTableTypeText}");
                    continue;
                }

                LogProvider.Log.Info($"Failed to duplicate {sourceLayout.Name}, {sourceTableTypeText} to {duplicateLayoutName}, {duplicateTableTypeText}");
            }
        }
コード例 #3
0
        public HudLayoutInfoV2 Migrate(HudLayoutInfo layout)
        {
            Check.Require(layout != null, "Layout must be not null");

            var hudLayoutInfoV2 = new HudLayoutInfoV2
            {
                Name                  = layout.Name,
                IsDefault             = layout.IsDefault,
                TableType             = layout.TableType,
                Opacity               = (double)layout.HudOpacity / 100,
                HudPlayerTypes        = layout.HudPlayerTypes.Select(x => x.Clone()).ToList(),
                HudBumperStickerTypes = layout.HudBumperStickerTypes.Select(x => x.Clone()).ToList()
            };

            if (layout.HudViewType == HudViewType.Plain)
            {
                MigratePlainLayout(layout, hudLayoutInfoV2);
            }
            else
            {
                MigrateRichLayout(layout, hudLayoutInfoV2);
            }

            return(hudLayoutInfoV2);
        }
コード例 #4
0
 /// <summary>
 /// Saves layout v2 to the specified file
 /// </summary>
 /// <param name="layoutFile"></param>
 /// <param name="layoutInfo"></param>
 private void SaveLayoutInfo(string layoutFile, HudLayoutInfoV2 layoutInfo)
 {
     using (var fs = File.Open(layoutFile, FileMode.Create))
     {
         var xmlSerializer = new XmlSerializer(typeof(HudLayoutInfoV2));
         xmlSerializer.Serialize(fs, layoutInfo);
     }
 }
コード例 #5
0
        private void SaveLayout(HudLayoutInfoV2 layout)
        {
            var fileName = ($"DH: {CommonResourceManager.Instance.GetEnumResource(layout.TableType)}.xml").RemoveInvalidFileNameChars();

            using (var fs = File.Open(fileName, FileMode.Create, FileAccess.ReadWrite, FileShare.Read))
            {
                var xmlSerializer = new XmlSerializer(typeof(HudLayoutInfoV2));
                xmlSerializer.Serialize(fs, layout);
            }
        }
コード例 #6
0
        public override void Configure(object viewModelInfo)
        {
            if (!(viewModelInfo is HudUploadToStoreViewModelInfo hudUploadToStoreViewModelInfo))
            {
                throw new ArgumentException(nameof(viewModelInfo));
            }

            hudLayout = hudUploadToStoreViewModelInfo.Layout;

            InitializeModelAsync(() => Model.Load());
        }
コード例 #7
0
        protected override void InitializeCommands()
        {
            var canSubmit = Observable.CombineLatest(
                this.WhenAny(x => x.HasErrors, x => x.IsValidating, (x1, x2) => !HasErrors && !IsValidating),
                images.Changed.Select(x => true).Merge(images.ItemChanged.Select(x => true)).Select(x => images.All(p => !p.HasErrors && !p.IsValidating)),
                (x1, x2) => x1 && x2);

            SubmitCommand = ReactiveCommand.Create(() => Upload(), canSubmit);

            CancelCommand = ReactiveCommand.Create(() => OnClosed());
            ResetCommand  = ReactiveCommand.Create(() => Reset());

            var canAddImage = images.Changed.Select(x => images.Count <= MaxImages).StartWith(true);

            AddImageCommand = ReactiveCommand.Create(() => AddImage(), canAddImage);

            var canRemoveImage = images.ItemChanged.Select(x => images.Any(p => p.IsSelected)).StartWith(false);

            RemoveImageCommand = ReactiveCommand.Create(() => RemoveImage(), canRemoveImage);

            BackCommand = ReactiveCommand.Create(() =>
            {
                Message = string.Empty;
                IsRetryButtonVisible  = false;
                IsSubmitButtonVisible = true;
            });

            var canSelect = this.WhenAny(x => x.CurrentLayout, x => x.Value != null);

            SelectLayoutCommand = ReactiveCommand.Create(() =>
            {
                hudLayout = CurrentLayout;

                IsSelectLayoutButtonVisible = false;
                IsSubmitButtonVisible       = true;
                IsResetButtonVisible        = true;

                SelectDefaultTableType();

                Name = hudLayout.Name;

                ApplyRules();

                this.RaisePropertyChanged(nameof(IsLayoutSelectionVisible));
                this.RaisePropertyChanged(nameof(IsUploadFormVisible));
            }, canSelect);
        }
コード例 #8
0
        private HudElementViewModel CreateHudElement(HudLayoutInfoV2 layout, EnumGameType enumGameType)
        {
            var hudElementCreator = new HudElementViewModelCreator();

            var hudElementCreationInfo = new HudElementViewModelCreationInfo
            {
                GameType      = enumGameType,
                HudLayoutInfo = layout,
                PokerSite     = EnumPokerSites.Ignition,
                SeatNumber    = 1
            };

            var hudElement = hudElementCreator.Create(hudElementCreationInfo);

            hudElement.PlayerName = "Player";
            hudElement.PlayerId   = 1;

            return(hudElement);
        }
コード例 #9
0
 protected override string InternalSave(HudLayoutInfoV2 hudLayoutInfo)
 {
     layouts.Add(hudLayoutInfo.Name, hudLayoutInfo);
     return(GetLayoutFileName(hudLayoutInfo.Name));
 }
コード例 #10
0
        /// <summary>
        /// Creates <see cref="HudLayoutInfoV2"/> for tests, all tools must be included
        /// </summary>
        /// <returns><see cref="HudLayoutInfoV2"/></returns>
        private static HudLayoutInfoV2 CreateHudLayoutInfo()
        {
            var hudLayoutInfo = new HudLayoutInfoV2
            {
                TableType = EnumTableType.HU,
                Name      = "TestLayout",
                Filter    = new HudLayoutFilter
                {
                    DataFreshness = 30,
                    TableTypes    = new[] { (int)EnumTableType.HU, (int)EnumTableType.Six }
                },
                TrackMeterPositions = new List <HudPositionsInfo>
                {
                    new HudPositionsInfo
                    {
                        GameType     = EnumGameType.MTTHoldem,
                        PokerSite    = EnumPokerSites.Bodog,
                        HudPositions = new List <HudPositionInfo>
                        {
                            new HudPositionInfo
                            {
                                Position = new System.Windows.Point(1, 15)
                            }
                        }
                    }
                }
            };

            var plainBoxTool = new HudLayoutPlainBoxTool
            {
                Positions = new List <HudPositionsInfo>
                {
                    new HudPositionsInfo
                    {
                        GameType     = EnumGameType.CashHoldem,
                        HudPositions = new List <HudPositionInfo>
                        {
                            new HudPositionInfo
                            {
                                Position = new System.Windows.Point(1, 1),
                                Seat     = 1,
                                Width    = 2
                            }
                        },
                        PokerSite = EnumPokerSites.Bodog
                    }
                },
                Stats = new ReactiveList <StatInfo>
                {
                    new StatInfo
                    {
                        Stat = Stat.VPIP
                    }
                }
            };

            var textboxTool = new HudLayoutTextBoxTool
            {
                Text = "Test"
            };

            var fourStatBoxTool = new HudLayoutFourStatsBoxTool
            {
                Positions = new List <HudPositionsInfo>
                {
                    new HudPositionsInfo
                    {
                        GameType     = EnumGameType.CashHoldem,
                        HudPositions = new List <HudPositionInfo>
                        {
                            new HudPositionInfo
                            {
                                Position = new System.Windows.Point(1, 1),
                                Seat     = 1,
                                Width    = 2
                            }
                        },
                        PokerSite = EnumPokerSites.Bodog
                    }
                },
                Stats = new ReactiveList <StatInfo>
                {
                    new StatInfo
                    {
                        Stat = Stat.VPIP
                    }
                }
            };

            var tiltMeterTool      = new HudLayoutTiltMeterTool();
            var playerIconTool     = new HudLayoutPlayerIconTool();
            var graphTool          = new HudLayoutGraphTool();
            var gaugeIndicatorTool = new HudLayoutGaugeIndicator();
            var bumperStickers     = new HudLayoutBumperStickersTool();
            var heatMap            = new HudLayoutHeatMapTool();

            hudLayoutInfo.LayoutTools = new List <HudLayoutTool> {
                plainBoxTool, textboxTool, fourStatBoxTool, tiltMeterTool, playerIconTool, graphTool, gaugeIndicatorTool, bumperStickers, heatMap
            };

            return(hudLayoutInfo);
        }
コード例 #11
0
        public void HudLayoutInfoV2CanBeSerializedDeserialized()
        {
            var hudLayoutExpected = CreateHudLayoutInfo();

            string serialized = null;

            Assert.DoesNotThrow(() =>
            {
                using (var sw = new StringWriter())
                {
                    var xmlSerializer = new XmlSerializer(typeof(HudLayoutInfoV2));
                    xmlSerializer.Serialize(sw, hudLayoutExpected);
                    serialized = sw.ToString();
                }
            });

            Assert.IsNotNull(serialized);

            HudLayoutInfoV2 hudLayoutActual = null;

            Assert.DoesNotThrow(() =>
            {
                using (var sr = new StringReader(serialized))
                {
                    var xmlSerializer = new XmlSerializer(typeof(HudLayoutInfoV2));
                    hudLayoutActual   = xmlSerializer.Deserialize(sr) as HudLayoutInfoV2;
                }
            });

            Assert.IsNotNull(hudLayoutActual);

            var actualTool   = hudLayoutActual.LayoutTools.OfType <HudLayoutPlainBoxTool>().First();
            var expectedTool = hudLayoutExpected.LayoutTools.OfType <HudLayoutPlainBoxTool>().First();

            Assert.That(actualTool.Id, Is.EqualTo(expectedTool.Id));

            var actualPositionInfo   = actualTool.Positions.FirstOrDefault();
            var expectedPositionInfo = expectedTool.Positions.FirstOrDefault();

            Assert.IsNotNull(actualPositionInfo);
            Assert.IsNotNull(expectedPositionInfo);
            Assert.IsNotNull(actualPositionInfo.HudPositions);
            Assert.IsNotNull(expectedPositionInfo.HudPositions);

            Assert.That(actualPositionInfo.GameType, Is.EqualTo(expectedPositionInfo.GameType));

            var actualPosition   = actualPositionInfo.HudPositions.FirstOrDefault();
            var expectedPosition = expectedPositionInfo.HudPositions.FirstOrDefault();

            Assert.That(actualPosition.Position, Is.EqualTo(actualPosition.Position));
            Assert.That(actualPosition.Width, Is.EqualTo(actualPosition.Width));
            Assert.That(actualPosition.Seat, Is.EqualTo(actualPosition.Seat));
            Assert.That(actualPosition.Height, Is.EqualTo(actualPosition.Height));
            Assert.That(hudLayoutActual.Filter, Is.EqualTo(hudLayoutExpected.Filter));

            Assert.That(hudLayoutActual.TrackMeterPositions.Count, Is.EqualTo(hudLayoutExpected.TrackMeterPositions.Count));

            for (var i = 0; i < hudLayoutActual.TrackMeterPositions.Count; i++)
            {
                var actualTrackMeter   = hudLayoutActual.TrackMeterPositions[i];
                var expectedTrackMeter = hudLayoutExpected.TrackMeterPositions[i];

                Assert.That(actualTrackMeter.GameType, Is.EqualTo(expectedTrackMeter.GameType));
                Assert.That(actualTrackMeter.PokerSite, Is.EqualTo(expectedTrackMeter.PokerSite));
                Assert.That(actualTrackMeter.HudPositions.Count, Is.EqualTo(expectedTrackMeter.HudPositions.Count));
            }
        }
コード例 #12
0
        private void MigratePlainLayout(HudLayoutInfo layout, HudLayoutInfoV2 layoutInfoV2)
        {
            var hudLayoutPlainBoxTool = new HudLayoutPlainBoxTool();

            hudLayoutPlainBoxTool.UIPositions = (from seat in Enumerable.Range(1, (int)layout.TableType)
                                                 let uiPosition = layout.UiPositionsInfo.FirstOrDefault(x => x.Seat == seat)
                                                                  let x = uiPosition != null ? uiPosition.Position.X + uiPositionShiftX : 0
                                                                          let y = uiPosition != null ? uiPosition.Position.Y : 0
                                                                                  select new HudPositionInfo
            {
                Seat = seat,
                Position = new Point(x, y),
                Width = uiPosition != null ? uiPosition.Width : HudDefaultSettings.PlainStatBoxWidth,
                Height = HudDefaultSettings.PlainStatBoxHeight,
            }).ToList();

            var clonedStats = layout.HudStats.Select(x => x.Clone()).ToList();

            // insert line breaks
            if (clonedStats.Count > 4 && clonedStats.All(x => !(x is StatInfoBreak)))
            {
                var clonedStatsWithBreaks = new List <StatInfo>();

                for (var i = 0; i < clonedStats.Count; i++)
                {
                    if (i > 0 && i % 4 == 0)
                    {
                        clonedStatsWithBreaks.Add(new StatInfoBreak());
                    }

                    clonedStatsWithBreaks.Add(clonedStats[i]);
                }

                clonedStats = clonedStatsWithBreaks;
            }

            hudLayoutPlainBoxTool.Stats = new ReactiveList <StatInfo>(clonedStats);

            hudLayoutPlainBoxTool.Positions = (from hudPositionsInfo in layout.HudPositionsInfo
                                               select new HudPositionsInfo
            {
                GameType = hudPositionsInfo.GameType,
                PokerSite = hudPositionsInfo.PokerSite,
                HudPositions = (from hudPosition in hudPositionsInfo.HudPositions
                                let offset = GetOffset(hudPositionsInfo.PokerSite, hudPositionsInfo.GameType, layout.TableType, hudPosition.Seat)
                                             select new HudPositionInfo
                {
                    Seat = hudPosition.Seat,
                    Position = new Point(hudPosition.Position.X + offset.X, hudPosition.Position.Y + offset.Y)
                }).ToList()
            }).ToList();

            var hudLayoutBumperStickersTool = new HudLayoutBumperStickersTool
            {
                UIPositions = (from position in hudLayoutPlainBoxTool.UIPositions
                               select new HudPositionInfo
                {
                    Seat = position.Seat,
                    Position = new Point(position.Position.X, position.Position.Y - HudDefaultSettings.BumperStickersHeight),
                    Width = HudDefaultSettings.BumperStickersWidth,
                    Height = HudDefaultSettings.BumperStickersHeight
                }).ToList(),
                Positions = (from positionsInfo in hudLayoutPlainBoxTool.Positions
                             select new HudPositionsInfo
                {
                    PokerSite = positionsInfo.PokerSite,
                    GameType = positionsInfo.GameType,
                    HudPositions = (from position in positionsInfo.HudPositions
                                    select new HudPositionInfo
                    {
                        Seat = position.Seat,
                        Position = new Point(position.Position.X, position.Position.Y - HudDefaultSettings.BumperStickersHeight)
                    }).ToList()
                }).ToList()
            };


            layoutInfoV2.LayoutTools = new List <HudLayoutTool> {
                hudLayoutPlainBoxTool, hudLayoutBumperStickersTool
            };

            MigratePopups(layout, layoutInfoV2);
        }
コード例 #13
0
        private void MigratePopups(HudLayoutInfo layout, HudLayoutInfoV2 layoutInfoV2)
        {
            if (layout.HudStats.Any(x => x.Stat == Stat.VPIP))
            {
                var hudLayoutVPIPGaugeIndicatorTool = new HudLayoutGaugeIndicator
                {
                    BaseStat   = CreateStatInfo(Stat.VPIP),
                    Text       = "TOTAL",
                    HeaderText = "VPIP",
                    Stats      = new ReactiveList <StatInfo>
                    {
                        CreateStatInfo(Stat.VPIP_EP),
                        CreateStatInfo(Stat.VPIP_MP),
                        CreateStatInfo(Stat.VPIP_CO),
                        CreateStatInfo(Stat.VPIP_BN),
                        CreateStatInfo(Stat.VPIP_SB),
                        CreateStatInfo(Stat.VPIP_BB),
                    }
                };

                var hudLayoutColdCallGaugeIndicatorTool = new HudLayoutGaugeIndicator
                {
                    BaseStat   = CreateStatInfo(Stat.VPIP),
                    Text       = "COLD CALL",
                    HeaderText = "Cold Call",
                    Stats      = new ReactiveList <StatInfo>
                    {
                        CreateStatInfo(Stat.ColdCall_EP),
                        CreateStatInfo(Stat.ColdCall_MP),
                        CreateStatInfo(Stat.ColdCall_CO),
                        CreateStatInfo(Stat.ColdCall_BN),
                        CreateStatInfo(Stat.ColdCall_SB),
                        CreateStatInfo(Stat.ColdCall_BB),
                    }
                };

                layoutInfoV2.LayoutTools.Add(hudLayoutVPIPGaugeIndicatorTool);
                layoutInfoV2.LayoutTools.Add(hudLayoutColdCallGaugeIndicatorTool);
            }

            if (layout.HudStats.Any(x => x.Stat == Stat.PFR))
            {
                var hudLayoutPFRGaugeIndicatorTool = new HudLayoutGaugeIndicator
                {
                    BaseStat   = CreateStatInfo(Stat.PFR),
                    Text       = "UNOPENED",
                    HeaderText = "PFR",
                    Stats      = new ReactiveList <StatInfo>
                    {
                        CreateStatInfo(Stat.UO_PFR_EP),
                        CreateStatInfo(Stat.UO_PFR_MP),
                        CreateStatInfo(Stat.UO_PFR_CO),
                        CreateStatInfo(Stat.UO_PFR_BN),
                        CreateStatInfo(Stat.UO_PFR_SB)
                    }
                };

                layoutInfoV2.LayoutTools.Add(hudLayoutPFRGaugeIndicatorTool);
            }

            if (layout.HudStats.Any(x => x.Stat == Stat.S3Bet))
            {
                var hudLayout3BetGaugeIndicatorTool = new HudLayoutGaugeIndicator
                {
                    BaseStat   = CreateStatInfo(Stat.S3Bet),
                    Text       = "TOTAL",
                    HeaderText = "3-bet%",
                    Stats      = new ReactiveList <StatInfo>
                    {
                        CreateStatInfo(Stat.ThreeBet_EP),
                        CreateStatInfo(Stat.ThreeBet_MP),
                        CreateStatInfo(Stat.ThreeBet_CO),
                        CreateStatInfo(Stat.ThreeBet_BN),
                        CreateStatInfo(Stat.ThreeBet_SB),
                        CreateStatInfo(Stat.ThreeBet_BB),
                    }
                };

                layoutInfoV2.LayoutTools.Add(hudLayout3BetGaugeIndicatorTool);
            }

            if (layout.HudStats.Any(x => x.Stat == Stat.AGG))
            {
                var hudLayoutAggGaugeIndicatorTool = new HudLayoutGaugeIndicator
                {
                    BaseStat   = CreateStatInfo(Stat.AGG),
                    Text       = "TOTAL",
                    HeaderText = "AGG%",
                    Stats      = new ReactiveList <StatInfo>
                    {
                        CreateStatInfo(Stat.FlopAGG),
                        CreateStatInfo(Stat.TurnAGG),
                        CreateStatInfo(Stat.RiverAGG),
                        CreateStatInfo(Stat.RecentAgg)
                    }
                };

                layoutInfoV2.LayoutTools.Add(hudLayoutAggGaugeIndicatorTool);
            }

            if (layout.HudStats.Any(x => x.Stat == Stat.PlayerInfoIcon))
            {
                var hudLayoutGraphTool = new HudLayoutGraphTool
                {
                    BaseStat = CreateStatInfo(Stat.PlayerInfoIcon),
                    Stats    = new ReactiveList <StatInfo> {
                        CreateStatInfo(Stat.NetWon)
                    }
                };

                layoutInfoV2.LayoutTools.Add(hudLayoutGraphTool);
            }
        }
コード例 #14
0
        private void MigrateRichLayout(HudLayoutInfo layout, HudLayoutInfoV2 layoutInfoV2)
        {
            // 4-stat box
            var hudLayout4StatBoxTool = new HudLayoutFourStatsBoxTool
            {
                IsVertical  = layout.HudViewType != HudViewType.Horizontal,
                UIPositions = (from seat in Enumerable.Range(1, (int)layout.TableType)
                               let uiPosition = layout.UiPositionsInfo.FirstOrDefault(x => x.Seat == seat)
                                                let shiftX = layout.HudViewType != HudViewType.Horizontal && IsRightOriented((int)layout.TableType, seat) ? ui4StatBoxVerticalShiftX : 0
                                                             let shiftY = layout.HudViewType == HudViewType.Horizontal ? ui4StatBoxHorizontalShiftY : 0
                                                                          let x = uiPosition != null ? uiPosition.Position.X + shiftX : 0
                                                                                  let y = uiPosition != null ? uiPosition.Position.Y + shiftY : 0
                                                                                          let width = layout.HudViewType != HudViewType.Horizontal ? HudDefaultSettings.FourStatVerticalBoxWidth : HudDefaultSettings.FourStatBoxWidth
                                                                                                      let height = layout.HudViewType != HudViewType.Horizontal ? HudDefaultSettings.FourStatVerticalBoxHeight : HudDefaultSettings.FourStatBoxHeight
                                                                                                                   select new HudPositionInfo
                {
                    Seat = seat,
                    Position = new Point(x, y + uiExtraShiftY),
                    Width = width,
                    Height = height,
                }).ToList(),
                Stats = new ReactiveList <StatInfo>(layout.HudStats
                                                    .Where(x => x.Stat != Stat.PlayerInfoIcon && x.Stat != Stat.LineBreak)
                                                    .Take(4)
                                                    .Select(x => x.Clone())),
                Positions = (from hudPositionsInfo in layout.HudPositionsInfo
                             select new HudPositionsInfo
                {
                    GameType = hudPositionsInfo.GameType,
                    PokerSite = hudPositionsInfo.PokerSite,
                    HudPositions = (from hudPosition in hudPositionsInfo.HudPositions
                                    let shiftX = layout.HudViewType != HudViewType.Horizontal && IsRightOriented((int)layout.TableType, hudPosition.Seat) ? ui4StatBoxVerticalShiftX : 0
                                                 let shiftY = layout.HudViewType == HudViewType.Horizontal ? ui4StatBoxHorizontalShiftY : 0
                                                              let offset = GetOffset(hudPositionsInfo.PokerSite, hudPositionsInfo.GameType, layout.TableType, hudPosition.Seat)
                                                                           select new HudPositionInfo
                    {
                        Seat = hudPosition.Seat,
                        Position = new Point(hudPosition.Position.X + offset.X + shiftX, hudPosition.Position.Y + offset.Y + shiftY)
                    }).ToList()
                }).ToList()
            };

            // add line breaks to vertical component
            var plainBoxStats = layout.HudStats
                                .Where(x => !hudLayout4StatBoxTool.Stats.Any(p => p.Stat == x.Stat))
                                .Select(x => x.Clone()).ToList();

            if (layout.HudViewType == HudViewType.Vertical_1)
            {
                var plainBoxStatsTemp = plainBoxStats.Where(x => x.Stat != Stat.LineBreak).ToList();
                plainBoxStats = new List <StatInfo>();

                for (var i = 0; i < plainBoxStatsTemp.Count; i++)
                {
                    plainBoxStats.Add(plainBoxStatsTemp[i]);

                    if (i != plainBoxStatsTemp.Count - 1)
                    {
                        plainBoxStats.Add(new StatInfoBreak());
                    }
                }
            }

            // plain box
            var hudLayoutPlainBoxTool = new HudLayoutPlainBoxTool
            {
                UIPositions = (from seat in Enumerable.Range(1, (int)layout.TableType)
                               let uiPosition = layout.UiPositionsInfo.FirstOrDefault(x => x.Seat == seat)
                                                let shiftX = layout.HudViewType == HudViewType.Vertical_1 ?
                                                             (IsRightOriented((int)layout.TableType, seat) ? uiPlainBoxVertical1RightOrientedShiftX : uiPlainBoxVertical1ShiftX) : 0
                                                             let shiftY = layout.HudViewType == HudViewType.Vertical_1 ? uiPlainBoxVerticalShiftY : uiPlainBoxShiftY + ui4StatBoxHorizontalShiftY
                                                                          let x = uiPosition != null ? uiPosition.Position.X + shiftX : 0
                                                                                  let y = uiPosition != null ? uiPosition.Position.Y + shiftY : 0
                                                                                          let width = layout.HudViewType == HudViewType.Vertical_1 ? uiPlainBoxVerticalWidth : HudDefaultSettings.FourStatBoxWidth
                                                                                                      let height = HudDefaultSettings.PlainStatBoxHeight
                                                                                                                   select new HudPositionInfo
                {
                    Seat = seat,
                    Position = new Point(x, y + uiExtraShiftY),
                    Width = width,
                    Height = height
                }).ToList(),

                Stats = new ReactiveList <StatInfo>(plainBoxStats),

                Positions = (from hudPositionsInfo in layout.HudPositionsInfo
                             select new HudPositionsInfo
                {
                    GameType = hudPositionsInfo.GameType,
                    PokerSite = hudPositionsInfo.PokerSite,
                    HudPositions = (from hudPosition in hudPositionsInfo.HudPositions
                                    let shiftX = layout.HudViewType == HudViewType.Vertical_1 ?
                                                 (IsRightOriented((int)layout.TableType, hudPosition.Seat) ? uiPlainBoxVertical1RightOrientedShiftX : uiPlainBoxVertical1ShiftX) : 0
                                                 let shiftY = layout.HudViewType == HudViewType.Vertical_1 ? uiPlainBoxVerticalShiftY : uiPlainBoxShiftY + ui4StatBoxHorizontalShiftY
                                                              let offset = GetOffset(hudPositionsInfo.PokerSite, hudPositionsInfo.GameType, layout.TableType, hudPosition.Seat)
                                                                           select new HudPositionInfo
                    {
                        Seat = hudPosition.Seat,
                        Position = new Point(hudPosition.Position.X + offset.X + shiftX, hudPosition.Position.Y + offset.Y + shiftY)
                    }).ToList()
                }).ToList()
            };

            // tilt meter
            var hudLayoutTiltMeterTool = new HudLayoutTiltMeterTool
            {
                UIPositions = (from seat in Enumerable.Range(1, (int)layout.TableType)
                               let uiPosition = layout.UiPositionsInfo.FirstOrDefault(x => x.Seat == seat)
                                                let shiftX = IsRightOriented((int)layout.TableType, seat) ? uiTiltMeterRightOrientedShiftX : 0
                                                             let shiftY = uiTiltMeterShiftY
                                                                          let x = uiPosition != null ? uiPosition.Position.X + shiftX : 0
                                                                                  let y = uiPosition != null ? uiPosition.Position.Y + shiftY : 0
                                                                                          let width = HudDefaultSettings.TiltMeterWidth
                                                                                                      let height = HudDefaultSettings.TiltMeterHeight
                                                                                                                   select new HudPositionInfo
                {
                    Seat = seat,
                    Position = new Point(x, y + uiExtraShiftY),
                    Width = width,
                    Height = height
                }).ToList(),

                Positions = (from hudPositionsInfo in layout.HudPositionsInfo
                             select new HudPositionsInfo
                {
                    GameType = hudPositionsInfo.GameType,
                    PokerSite = hudPositionsInfo.PokerSite,
                    HudPositions = (from hudPosition in hudPositionsInfo.HudPositions
                                    let shiftX = IsRightOriented((int)layout.TableType, hudPosition.Seat) ? uiTiltMeterRightOrientedShiftX : 0
                                                 let shiftY = uiTiltMeterShiftY
                                                              let offset = GetOffset(hudPositionsInfo.PokerSite, hudPositionsInfo.GameType, layout.TableType, hudPosition.Seat)
                                                                           select new HudPositionInfo
                    {
                        Seat = hudPosition.Seat,
                        Position = new Point(hudPosition.Position.X + offset.X + shiftX, hudPosition.Position.Y + offset.Y + shiftY)
                    }).ToList()
                }).ToList()
            };

            // player icon
            var hudLayoutPlayerIconTool = new HudLayoutPlayerIconTool
            {
                UIPositions = (from seat in Enumerable.Range(1, (int)layout.TableType)
                               let uiPosition = layout.UiPositionsInfo.FirstOrDefault(x => x.Seat == seat)
                                                let shiftX = IsRightOriented((int)layout.TableType, seat) ? uiPlayerIconRightOrientedShiftX : uiPlayerIconShiftX
                                                             let shiftY = uiPlayerIconShiftY
                                                                          let x = uiPosition != null ? uiPosition.Position.X + shiftX : 0
                                                                                  let y = uiPosition != null ? uiPosition.Position.Y + shiftY : 0
                                                                                          let width = HudDefaultSettings.PlayerIconWidth
                                                                                                      let height = HudDefaultSettings.PlayerIconHeight
                                                                                                                   select new HudPositionInfo
                {
                    Seat = seat,
                    Position = new Point(x, y + uiExtraShiftY),
                    Width = width,
                    Height = height
                }).ToList(),

                Positions = (from hudPositionsInfo in layout.HudPositionsInfo
                             select new HudPositionsInfo
                {
                    GameType = hudPositionsInfo.GameType,
                    PokerSite = hudPositionsInfo.PokerSite,
                    HudPositions = (from hudPosition in hudPositionsInfo.HudPositions
                                    let shiftX = IsRightOriented((int)layout.TableType, hudPosition.Seat) ? uiPlayerIconRightOrientedShiftX : uiPlayerIconShiftX
                                                 let shiftY = uiPlayerIconShiftY
                                                              let offset = GetOffset(hudPositionsInfo.PokerSite, hudPositionsInfo.GameType, layout.TableType, hudPosition.Seat)
                                                                           select new HudPositionInfo
                    {
                        Seat = hudPosition.Seat,
                        Position = new Point(hudPosition.Position.X + offset.X + shiftX, hudPosition.Position.Y + offset.Y + shiftY)
                    }).ToList()
                }).ToList()
            };

            var hudLayoutGraphTool = new HudLayoutGraphTool
            {
                ParentId = hudLayoutPlayerIconTool.Id,
                Stats    = new ReactiveList <StatInfo> {
                    CreateStatInfo(Stat.NetWon)
                }
            };

            // bumper stickers
            var hudLayoutBumperStickersTool = new HudLayoutBumperStickersTool
            {
                UIPositions = (from seat in Enumerable.Range(1, (int)layout.TableType)
                               let uiPosition = layout.UiPositionsInfo.FirstOrDefault(x => x.Seat == seat)
                                                let shiftX = layout.HudViewType == HudViewType.Vertical_1 ?
                                                             (IsRightOriented((int)layout.TableType, seat) ? uiPlainBoxVertical1RightOrientedShiftX : uiPlainBoxVertical1ShiftX) : 0
                                                             let shiftY = layout.HudViewType == HudViewType.Vertical_1 ? uiPlainBoxVerticalShiftY : uiPlainBoxShiftY + ui4StatBoxHorizontalShiftY
                                                                          let x = uiPosition != null ? uiPosition.Position.X + shiftX : 0
                                                                                  let y = (uiPosition != null ? uiPosition.Position.Y + shiftY : 0) + uiBumperStickerShiftY
                                                                                          let width = HudDefaultSettings.BumperStickersWidth
                                                                                                      let height = HudDefaultSettings.BumperStickersHeight
                                                                                                                   select new HudPositionInfo
                {
                    Seat = seat,
                    Position = new Point(x, y + uiExtraShiftY),
                    Width = width,
                    Height = height
                }).ToList(),

                Positions = (from hudPositionsInfo in layout.HudPositionsInfo
                             select new HudPositionsInfo
                {
                    GameType = hudPositionsInfo.GameType,
                    PokerSite = hudPositionsInfo.PokerSite,
                    HudPositions = (from hudPosition in hudPositionsInfo.HudPositions
                                    let shiftX = layout.HudViewType == HudViewType.Vertical_1 ?
                                                 (IsRightOriented((int)layout.TableType, hudPosition.Seat) ? uiPlainBoxVertical1RightOrientedShiftX : uiPlainBoxVertical1ShiftX) : 0
                                                 let shiftY = layout.HudViewType == HudViewType.Vertical_1 ? uiPlainBoxVerticalShiftY : uiPlainBoxShiftY + ui4StatBoxHorizontalShiftY
                                                              let offset = GetOffset(hudPositionsInfo.PokerSite, hudPositionsInfo.GameType, layout.TableType, hudPosition.Seat)
                                                                           select new HudPositionInfo
                    {
                        Seat = hudPosition.Seat,
                        Position = new Point(hudPosition.Position.X + offset.X + shiftX, hudPosition.Position.Y + offset.Y + shiftY + uiBumperStickerShiftY)
                    }).ToList()
                }).ToList()
            };

            layoutInfoV2.LayoutTools = new List <HudLayoutTool> {
                hudLayout4StatBoxTool, hudLayoutPlainBoxTool, hudLayoutTiltMeterTool, hudLayoutPlayerIconTool, hudLayoutGraphTool, hudLayoutBumperStickersTool
            };

            MigratePopups(layout, layoutInfoV2);
        }
コード例 #15
0
        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);
        }