Exemple #1
0
        /// <summary>
        /// Gets the list of <see cref="HudPositionInfo"/> related to base position in designer
        /// </summary>
        /// <param name="tableType"><see cref="EnumTableType"/> of table</param>
        /// <param name="relativeTableType"><see cref="EnumTableType"/> to which position is set</param>
        /// <param name="position"><see cref="Point"/> position of base element</param>
        /// <returns>The list of <see cref="HudPositionInfo"/></returns>
        public List <HudPositionInfo> GetHudUIPositions(EnumTableType tableType, EnumTableType relativeTableType, Point position)
        {
            var positions = new List <HudPositionInfo>();

            var seats = (int)tableType;
            var relativeTableSeats = (int)relativeTableType;

            var playerLabelPositions         = HudDefaultSettings.TablePlayerLabelPositions[seats];
            var relativePlayerLabelPositions = HudDefaultSettings.TablePlayerLabelPositions[relativeTableSeats];

            var relativePlayerLabelPositionX = relativePlayerLabelPositions[0, 0];
            var relativePlayerLabelPositionY = relativePlayerLabelPositions[0, 1];

            var deltaX = position.X - relativePlayerLabelPositionX;
            var deltaY = position.Y - relativePlayerLabelPositionY;

            for (var seat = 0; seat < seats; seat++)
            {
                var playerLabelPositionX = playerLabelPositions[seat, 0];
                var playerLabelPositionY = playerLabelPositions[seat, 1];

                var positionInfo = new HudPositionInfo
                {
                    Position = new Point(playerLabelPositionX + deltaX, playerLabelPositionY + deltaY),
                    Seat     = seat + 1
                };

                positions.Add(positionInfo);
            }

            return(positions);
        }
        /// <summary>
        /// Initializes position and size for the current <see cref="HudPlainStatBoxViewModel"/> for the specified <see cref="EnumPokerSites"/> and <see cref="EnumGameType"/>
        /// </summary>
        /// <param name="pokerSite"><see cref="EnumPokerSites"/></param>
        /// <param name="gameType"><see cref="EnumGameType"/></param>
        /// <exception cref="DHBusinessException" />
        public override void InitializePositions(EnumPokerSites pokerSite, EnumTableType tableType, EnumGameType gameType)
        {
            if (!(Tool is T tool))
            {
                return;
            }

            var seats       = (int)tableType;
            var currentSeat = Parent.Seat - 1;

            var uiPosition = tool.UIPositions.FirstOrDefault(x => x.Seat == Parent.Seat);

            if (uiPosition == null)
            {
                LogProvider.Log.Warn($"Could not find UI positions for {pokerSite}, {gameType}, {Parent.Seat}, {tool.ToolType}");
            }

            var positionInfo = tool.Positions.FirstOrDefault(x => x.PokerSite == pokerSite && x.GameType == gameType);

            var hudPositionInfo = positionInfo?.HudPositions.FirstOrDefault(x => x.Seat == Parent.Seat);

            if (hudPositionInfo == null)
            {
                var positionProvider = ServiceLocator.Current.GetInstance <IPositionProvider>(pokerSite.ToString());

                if (!positionProvider.Positions.ContainsKey(seats))
                {
                    throw new DHBusinessException(new NonLocalizableString($"Could not find predefined positions for {pokerSite}, {gameType}, {Parent.Seat}"));
                }

                var playerLabelClientPosition = positionProvider.Positions[seats];

                var playerLabelPosition = HudDefaultSettings.TablePlayerLabelPositions[seats];

                var offsetX = playerLabelClientPosition[currentSeat, 0] - playerLabelPosition[currentSeat, 0];
                var offsetY = playerLabelClientPosition[currentSeat, 1] - playerLabelPosition[currentSeat, 1];

                var positionX = uiPosition != null ? uiPosition.Position.X : default(double);
                var positionY = uiPosition != null ? uiPosition.Position.Y : default(double);

                // do not change position if element is inside or above player label
                if (positionY > playerLabelPosition[currentSeat, 1] + HudDefaultSettings.TablePlayerLabelActualHeight)
                {
                    offsetY += positionProvider.PlayerLabelHeight - HudDefaultSettings.TablePlayerLabelHeight;
                }

                hudPositionInfo = new HudPositionInfo
                {
                    Seat     = Parent.Seat,
                    Position = new Point(positionX + offsetX, positionY + offsetY)
                };
            }

            Position = hudPositionInfo.Position;
            Opacity  = Parent.Opacity;

            Width  = uiPosition != null && uiPosition.Width != 0 && !UseDefaultSizesOnly ? uiPosition.Width : DefaultWidth;
            Height = uiPosition != null && uiPosition.Height != 0 && !UseDefaultSizesOnly ? uiPosition.Height : DefaultHeight;
        }
Exemple #3
0
        /// <summary>
        /// Gets the list of <see cref="HudPositionInfo"/> of element for the specified <see cref="EnumPokerSites"/>, <see cref="EnumTableType"/>
        /// </summary>
        /// <param name="pokerSite"></param>
        /// <param name="tableType"></param>
        /// <param name="position"></param>
        /// <returns></returns>
        private List <HudPositionInfo> GetHudPositionInfo(EnumPokerSites pokerSite, EnumTableType tableType, Point position)
        {
            var positionsInfo = new List <HudPositionInfo>();

            // in designer only 2-max and 1st seat are available
            var labelPositions = HudDefaultSettings.TablePlayerLabelPositions[(int)EnumTableType.HU];

            var labelPositionX = labelPositions[0, 0];
            var labelPositionY = labelPositions[0, 1];

            var offsetX = position.X - labelPositionX;
            var offsetY = position.Y - labelPositionY;

            var positionProvider = ServiceLocator.Current.GetInstance <IPositionProvider>(pokerSite.ToString());

            var seats = (int)tableType;

            var tableTypeSize = (int)tableType;

            if (!positionProvider.Positions.ContainsKey(tableTypeSize))
            {
                return(positionsInfo);
            }

            var positions = positionProvider.Positions[tableTypeSize];

            for (var seat = 0; seat < seats; seat++)
            {
                var positionX = positions[seat, 0];
                var positionY = positions[seat, 1];

                var positionInfo = new HudPositionInfo
                {
                    Seat     = seat + 1,
                    Position = new Point(positionX + offsetX, positionY + offsetY)
                };

                positionsInfo.Add(positionInfo);
            }

            return(positionsInfo);
        }