示例#1
0
        void DrawString(string str, Vector2 pos, ScreenPositions origin, Color color)
        {
            Vector2 FontOrigin;

            FontOrigin = ArialFont.MeasureString(str) / 2;
            //for text alignment
            switch (origin)
            {
            case ScreenPositions.Right:
                FontOrigin = ArialFont.MeasureString(str);
                //FontOrigin.X = FontOrigin.X;
                break;

            case ScreenPositions.Left:
                FontOrigin   = ArialFont.MeasureString(str);
                FontOrigin.X = 0;
                break;

            case ScreenPositions.Centre:
                FontOrigin = ArialFont.MeasureString(str) / 2;
                break;
            }


            spriteBatch.DrawString(ArialFont, str, pos, color,
                                   0, FontOrigin, 1.0f, SpriteEffects.None, 0.0f);
        }
示例#2
0
        private void SetPositionButton(ScreenPositions position)
        {
            TopLeftToolStripButton.Checked     = position == ScreenPositions.TopLeft;
            TopRightToolStripButton.Checked    = position == ScreenPositions.TopRight;
            BottomLeftToolStripButton.Checked  = position == ScreenPositions.BottomLeft;
            BottomRightToolStripButton.Checked = position == ScreenPositions.BottomRight;

            Program.Settings.ScreenPosition = position;
        }
示例#3
0
 public Listbox(UIManager uim, Vector2 pos, Vector2 itemsize, Vector2 maxsize, ScreenPositions screenRelativePos = ScreenPositions.None)
 {
     uiManager = uim;
     mainList = new List<DisplayRect>();
     position = positionOffset = pos;
     itemSize = itemsize;
     maxSize = maxsize;
     selectedItem = null;
     screenRelative = screenRelativePos;
 }
        private List <PositionTargetAssociation> PositionTargetAssociations(ScreenPositions assoc)
        {
            var results = new List <PositionTargetAssociation>();

            foreach (var position in assoc.Positions)
            {
                var cursorScreenIndex = position.Cursor.Screen;
                var rectangle         = GetRectangle(assoc.Screens[cursorScreenIndex].Bounds, position.Cursor);
                var targetScreen      = assoc.Screens[position.Target.Screen];
                var targetPosition    = position.Target.Position;
                var size = position.Target.Size ?? _configuration.Size;
                results.Add(new PositionTargetAssociation(rectangle, targetScreen, targetPosition, size));
            }

            return(results);
        }
示例#5
0
        void SetupSelectedTank(TankType t, Tank p, ScreenPositions Start)
        {
            //----Tank----
            //name, topspeed, reversespeed, enginebraking, rotationspeed,
            //weight, horsepower, hitpoints

            //----Ammo----
            //name, storage, range, speed, reload



            switch (t)
            {
            case TankType.Destroyer:
            {
                TankData(p, "Destroyer", 37, 12, 0.03f, 0.04f, 1500.0f, 320.0f, 200, AmmoType.shell_12mm);
                AmmoData(p, "12mm Shell", 88, 200.0f, 4.0f, 2.0f, 1.5f);
            }
            break;

            case TankType.Heavy:
            {
                TankData(p, "Heavy Tank", 20, 8, 0.04f, 0.01f, 3300.0f, 400.0f, 450, AmmoType.shell_8mm);
                AmmoData(p, "8mm Shell", 68, 250.0f, 5.3f, 1.5f, 1.0f);
            }
            break;

            case TankType.Medium:
            {
                TankData(p, "Medium Tank", 30, 10, 0.05f, 0.025f, 2500.0f, 350.0f, 320, AmmoType.shell_3mm);
                AmmoData(p, "3mm Shell", 150, 150.0f, 6.9f, 0.6f, 0.4f);
            }
            break;
            }
            currentState = GameState.TankConfirm;

            p.ResetPosition(StartPos[(int)Start]);
            p.SetRotationAngle(Angles[(int)Start]);
            p.ResetSpeed();
        }
示例#6
0
        Color textColor; //, bgColor;

        #endregion Fields

        #region Constructors

        public DisplayRect(ContentManager content, string texturePath, Vector2 endSize, Vector2 offset, ScreenPositions screenRelativePos = ScreenPositions.None, string str = null, float pDepth = 1.0f)
        {
            if(texturePath != string.Empty)
                texture = content.Load<Texture2D>(texturePath);
            positionOffset = offset;
            displayString = str;
            screenRelative = screenRelativePos;
            size = endSize;
            font = Globals.gFonts["Miramonte"];
            if (texture != null)
                scale = new Vector2(size.X / texture.Width, size.Y / texture.Height);
            else
                scale = Vector2.One;
            textColor = Color.Green;
            //bgColor = Color.Transparent;
            depth = pDepth;

            if(displayString != null && displayString != string.Empty)
                displayString = Text.WrapText(font, displayString, size.X);
            if (screenRelativePos == ScreenPositions.None)
                position = offset;
        }
        MoveToPosition GetMoveToPosition(ArrangeDirection arrangeDirection, System.Drawing.Rectangle screenRectangle, int centerWindowSize, int leftRightWindowSize, ScreenPositions screenPostions)
        {
            MoveToPosition mtp = MoveToPosition.Undecided;
            var            awr = GetActiveWindowRectangle();
// needed 1px on 34" uwqhd 21:9 3440x1440 @ 100%, 2px on 25" wqhd 16:9 2560x1440 @ 125% [ , 3px on 13" wqhd @ 175% scale ] and ease of access [ win+u ] | display | make text bigger = 100% (default)
// using 3px appeared to break behavior back on 25" display where win+leftarrow state ctrl+leftarrow cycled to right 3rd instead of left 2/3rds and visa versa for starting with win+rightarrow state
            const int pixelError = 2;

            if (arrangeDirection == ArrangeDirection.Left)
            {
                if (screenPostions == ScreenPositions.LeftCenterRight)
                {
                    if (awr.Left - pixelError > screenRectangle.Left + leftRightWindowSize + centerWindowSize)
                    {
                        mtp = MoveToPosition.Right;
                    }
                    else if (awr.Left > screenRectangle.Left + leftRightWindowSize)
                    {
                        mtp = MoveToPosition.Center;
                    }
                    else if (awr.Left == screenRectangle.Left + leftRightWindowSize && Math.Abs(awr.Right - (screenRectangle.Left + leftRightWindowSize + centerWindowSize)) > pixelError)
                    {
                        mtp = MoveToPosition.Center;
                    }
                    else if (awr.Left == screenRectangle.Left + leftRightWindowSize && awr.Right <= screenRectangle.Left + leftRightWindowSize + centerWindowSize)
                    {
                        mtp = MoveToPosition.Left;
                    }
                    else if (awr.Left > screenRectangle.Left)
                    {
                        mtp = MoveToPosition.Left;
                    }
                    else if (awr.Left <= screenRectangle.Left && awr.Right > screenRectangle.Left + leftRightWindowSize)
                    {
                        mtp = MoveToPosition.Left;                                                                                                  // store apps repro the <=
                    }
                    else /* if (awr.Left <= screeRectangle.Left && awr.Right <= screenRectangle.Left + leftRightWindowSize) */ mtp {
        /// <summary>
        /// Take current active window and place it in left or right 3rd of screen area.
        /// </summary>
        /// <param name="centerPercentageOfTotalWidth">Percentage of total width to use when moving window, default is 34, with suggested alternatives being 36-38-40.</param>
        /// <param name="topBottomBorder">Number of pixels to use as border across top and bottom, default is 0.</param>
        /// <param name="screenPostions">defines type of screen positions scenario to base action on, default is LeftCenterRight.</param>
        public void PlaceActiveWindowPosition(ArrangeDirection arrangeDirection, int centerPercentageOfTotalWidth = 34, int topBottomBorder = 0, ScreenPositions screenPositions = ScreenPositions.LeftCenterRight)
        {
            //if (arrangeDirection == ArrangeDirection.Up || arrangeDirection == ArrangeDirection.Down)
            //{
            //        throw new ApplicationException("unsupported arrange direction specified");
            //}

            var awh = GetActiveWindowHandle();

// if you resize active window that is currently in SW_MAXIMIZE state it ends up not resizing it at all, e.g. in case of chrome, or
// resizing it but with an appx 7px space across top and bottom of window and if you minimize it and then restore it comes back as
// SW_MAXIMIZE state not expected SW_SHOW[NORMAL] state. so we check for SW_MAXIMIZE state and change to SW_SHOW[NORMAL] before
// resizing
            /* if (!IsWindowInNormalState(awh)) */ PutWindowIntoNormalState(awh);

            var primaryScreen = Screen.PrimaryScreen;
//#if DEBUG
//            var allScreens = Screen.AllScreens; var heightOfTaskbar = primaryScreen.Bounds.Bottom - primaryScreen.WorkingArea.Bottom;
//#endif
            //var sr = GetScreenRectangle(); // doesn't account for taskbar which you'd have to hardcode depending on display | scale and layout | size of . . .  + resolution settings
            var sr = primaryScreen.WorkingArea; // accounts for taskbar

            // splitting screen into 3rds is always going to require center 3rd to be rounded up to even number to end up with integer/whole numbers for left and right 3rds
            var centerWindowSize = (sr.Right - sr.Left) * centerPercentageOfTotalWidth / 100;
            var leftRightPercentageOfTotalWidth = (100 - centerPercentageOfTotalWidth) / 2;
            var leftRightWindowSize             = (sr.Right - sr.Left) * leftRightPercentageOfTotalWidth / 100;
            //var centerWindowSize = (sr.Right - sr.Left) - (leftRightWindowSize * 2);

            var position = new Rect()
            {
                Top = sr.Top + topBottomBorder
            };

            position.Bottom = sr.Bottom - topBottomBorder - position.Top; // change in y not absolution y position

            MoveToPosition mtp = GetMoveToPosition(arrangeDirection, sr, centerWindowSize, leftRightWindowSize, screenPositions);

            if (mtp == MoveToPosition.Left)
            {
                position.Left  = 0;
                position.Right = leftRightWindowSize; // change in x not absolution x position
            }
            else if (mtp == MoveToPosition.LeftTwoThirds)
            {
                position.Left  = 0;
                position.Right = leftRightWindowSize + centerWindowSize; // change in x not absolution x position
            }
            else if (mtp == MoveToPosition.Center)
            {
                position.Left = sr.Left + leftRightWindowSize;
                //position.Left = sr.Right - leftRightWindowSize - centerWindowSize; // alternative calculation
                position.Right = centerWindowSize; // change in x not absolution x position
            }
            else if (mtp == MoveToPosition.RightTwoThirds)
            {
                position.Left = sr.Right - leftRightWindowSize - centerWindowSize;
                //position.Left = sr.Left + leftRightWindowSize; // alternative calculation
                position.Right = centerWindowSize + leftRightWindowSize; // change in x not absolution x position
            }
            else if (mtp == MoveToPosition.Right)
            {
                position.Left = sr.Right - leftRightWindowSize;
                //position.Left = sr.Left + leftRightWindowSize + centerWindowSize; // alternative calculation
                position.Right = leftRightWindowSize; // change in x not absolution x position
            }

            // here is a a couple ways to add/subtract from top/bottom position settings in special app cases or uwp vs desktop app cases
            //var awt = GetActiveWindowTitle();
            //if (awt.EndsWith("- Special App Case 1") || awt.EndsWith("- Special App Case 2")) position.Bottom += 7;
            //var awh = GetActiveWindowHandle(); // this approach throws exceptions in IsUwpApp cases not seen in unit test runs that needs to be debugged
            //foreach (var process in Process.GetProcesses()) { if (process.MainWindowHandle == awh && process.IsUwpApp()) { position.Bottom += 7; break; } }

            SetActiveWindowPosition(position.Left, position.Top, position.Right, position.Bottom);
        }
示例#9
0
 public DisplayRect(string str, Vector2 endSize, Vector2 offset, ScreenPositions posRelative = ScreenPositions.None, float pDepth = 1.0f)
     : this(null, string.Empty, endSize, offset, posRelative, str, pDepth)
 {
 }
示例#10
0
        private void SetPositionButton(ScreenPositions position)
        {
            TopLeftToolStripButton.Checked = position == ScreenPositions.TopLeft;
            TopRightToolStripButton.Checked = position == ScreenPositions.TopRight;
            BottomLeftToolStripButton.Checked = position == ScreenPositions.BottomLeft;
            BottomRightToolStripButton.Checked = position == ScreenPositions.BottomRight;

            Program.Settings.ScreenPosition = position;
        }