示例#1
0
        private void AddPlayer(int i, float playerWidth, float playerHeight, float offset)
        {
            Rectangle  r      = RectangleUtil.Float(50 + ((playerWidth + offset) * i), 100, playerWidth, playerHeight);
            PlayerInfo player = new PlayerInfo();

            player.EditBounds = r;
            profile.PlayerData.Add(player);
        }
示例#2
0
        private void UpdateScreens()
        {
            if (screens == null)
            {
                screens     = ScreensUtil.AllScreens();
                totalBounds = RectangleUtil.Union(screens);
            }
            else
            {
                UserScreen[] newScreens = ScreensUtil.AllScreens();
                Rectangle    newBounds  = RectangleUtil.Union(newScreens);
                if (newBounds.Equals(totalBounds))
                {
                    return;
                }

                // screens got updated, need to reflect in our window
                screens     = newScreens;
                totalBounds = newBounds;

                // remove all players screens
                List <PlayerInfo> playerData = profile.PlayerData;
                if (playerData != null)
                {
                    for (int i = 0; i < playerData.Count; i++)
                    {
                        PlayerInfo player = playerData[i];
                        player.EditBounds  = GetDefaultBounds(draggingIndex);
                        player.ScreenIndex = -1;
                    }
                }
            }

            screensArea = new RectangleF(10, 50 + Height * 0.2f + 10, Width - 20, Height * 0.5f);
            if (totalBounds.Width > totalBounds.Height)
            {
                // horizontal monitor setup
                scale = screensArea.Width / (float)totalBounds.Width;
                if (totalBounds.Height * scale > screensArea.Height)
                {
                    scale = screensArea.Height / (float)totalBounds.Height;
                }
            }
            else
            {
                // vertical monitor setup
                scale = screensArea.Height / (float)totalBounds.Height;
                if (totalBounds.Width * scale > screensArea.Width)
                {
                    scale = screensArea.Width / (float)totalBounds.Width;
                }
            }

            Rectangle scaledBounds = RectangleUtil.Scale(totalBounds, scale);

            scaledBounds.X = (int)screensArea.X;
            scaledBounds.Y = (int)screensArea.Y;
            //scaledBounds = RectangleUtil.Center(scaledBounds, RectangleUtil.Float(0, this.Height * 0.25f, this.Width, this.Height * 0.7f));

            int minY = 0;

            for (int i = 0; i < screens.Length; i++)
            {
                UserScreen screen = screens[i];

                Rectangle bounds   = RectangleUtil.Scale(screen.MonitorBounds, scale);
                Rectangle uiBounds = new Rectangle(bounds.X, bounds.Y + scaledBounds.Y, bounds.Width, bounds.Height);
                screen.UIBounds = uiBounds;

                minY = Math.Min(minY, uiBounds.X);
            }

            // remove negative monitors
            minY = -minY;
            for (int i = 0; i < screens.Length; i++)
            {
                UserScreen screen = screens[i];

                Rectangle uiBounds = screen.UIBounds;
                uiBounds.X           += minY + scaledBounds.X;
                screen.UIBounds       = uiBounds;
                screen.SwapTypeBounds = RectangleUtil.Float(uiBounds.X, uiBounds.Y, uiBounds.Width * 0.1f, uiBounds.Width * 0.1f);
            }
        }