internal WinPosition(NativeMethods.TITLEBARINFO pti)
 {
     Left   = pti.rcTitleBar.left;
     Top    = pti.rcTitleBar.top;
     Right  = pti.rcTitleBar.right;
     Bottom = pti.rcTitleBar.bottom;
 }
Esempio n. 2
0
        private bool IsAltTabWindow(IntPtr hwnd)
        {
            NativeMethods.TITLEBARINFO ti = new NativeMethods.TITLEBARINFO();
            IntPtr hwndTry, hwndWalk = IntPtr.Zero;

            if (!NativeMethods.IsWindowVisible(hwnd))
            {
                return(false);
            }

            hwndTry = NativeMethods.GetAncestor(hwnd, Constant.GA_ROOTOWNER);
            while (hwndTry != hwndWalk)
            {
                hwndWalk = hwndTry;
                hwndTry  = NativeMethods.GetLastActivePopup(hwndWalk);
                if (NativeMethods.IsWindowVisible(hwndTry))
                {
                    break;
                }
            }
            if (hwndWalk != hwnd)
            {
                return(false);
            }

            // the following removes some task tray programs and "Program Manager"
            NativeMethods.GetTitleBarInfo(hwnd, ref ti);
            if ((ti.rgstate[0] & Constant.STATE_SYSTEM_INVISIBLE) != 0)
            {
                return(false);
            }

            // Tool windows should not be displayed either, these do not appear in the
            // task bar.
            if ((NativeMethods.GetWindowLong(hwnd, Constant.GWL_EXSTYLE) & Constant.WS_EX_TOOLWINDOW) != 0)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 3
0
        public WinPosition(NativeMethods.TITLEBARINFO pti)
        {
            label_1 :
            int num1 = -1613322285;

            while (true)
            {
                int  num2 = -1002061423;
                uint num3;
                switch ((num3 = (uint)(num1 ^ num2)) % 11U)
                {
                case 0:
                    goto label_3;

                case 1:
                    this.Top = pti.rcTitleBar.top;
                    num1     = (int)num3 * 203006237 ^ 1358508778;
                    continue;

                case 2:
                    this.Left = pti.rcTitleBar.left;
                    num1      = (int)num3 * -1015340728 ^ 703870521;
                    continue;

                case 3:
                    num1 = (int)num3 * 667051298 ^ -267995897;
                    continue;

                case 4:
                    this.Right = pti.rcTitleBar.right;
                    num1       = (int)num3 * 2101824383 ^ -1923197498;
                    continue;

                case 5:
                    num1 = (int)num3 * -1287946787 ^ 1450230057;
                    continue;

                case 6:
                    goto label_1;

                case 7:
                    num1 = (int)num3 * -1899568101 ^ -1794337315;
                    continue;

                case 8:
                    num1 = (int)num3 * 724358344 ^ 481497679;
                    continue;

                case 9:
                    num1 = (int)num3 * -906870680 ^ -453736585;
                    continue;

                case 10:
                    this.Bottom = pti.rcTitleBar.bottom;
                    num1        = (int)num3 * 1373610291 ^ -1933420476;
                    continue;

                default:
                    goto label_13;
                }
            }
label_13:
            return;

            label_3 :;
        }
Esempio n. 4
0
        public WinPosition(NativeMethods.TITLEBARINFO pti)
        {
label_1:
            int num1 = 1942692917;

            while (true)
            {
                int  num2 = 399678149;
                uint num3;
                switch ((num3 = (uint)(num1 ^ num2)) % 11U)
                {
                case 0:
                    this.Top = pti.rcTitleBar.top;
                    num1     = (int)num3 * 913341613 ^ 1225683768;
                    continue;

                case 1:
                    num1 = (int)num3 * -1565613516 ^ -1750776440;
                    continue;

                case 2:
                    goto label_1;

                case 3:
                    this.Left = pti.rcTitleBar.left;
                    num1      = (int)num3 * -1409279242 ^ 14216600;
                    continue;

                case 4:
                    num1 = (int)num3 * 1637811204 ^ 605355680;
                    continue;

                case 5:
                    num1 = (int)num3 * 1041750215 ^ 388173894;
                    continue;

                case 6:
                    num1 = (int)num3 * -103983641 ^ 1040575942;
                    continue;

                case 7:
                    num1 = (int)num3 * -171131827 ^ -255451686;
                    continue;

                case 8:
                    this.Bottom = pti.rcTitleBar.bottom;
                    num1        = (int)num3 * -549010213 ^ -1106748807;
                    continue;

                case 9:
                    this.Right = pti.rcTitleBar.right;
                    num1       = (int)num3 * 525005261 ^ 308523584;
                    continue;

                case 10:
                    goto label_3;

                default:
                    goto label_13;
                }
            }
label_13:
            return;

            label_3 :;
        }
Esempio n. 5
0
        Entity.Collider checkWindowCollision(Rectangle collider, CollisionDirection direction = CollisionDirection.None, bool bounce = false)
        {
            Entity.Collider collided = new Entity.Collider {
                Direction = CollisionDirection.None, Bounds = new Rectangle()
            };
            NativeMethods.EnumWindows(delegate(IntPtr hWnd, int lParam)
            {
                if (hWnd == Handle)
                {
                    return(true);
                }
                NativeMethods.TITLEBARINFO info = new NativeMethods.TITLEBARINFO();
                NativeMethods.GetTitleBarInfo(hWnd, ref info);
                if ((info.rgstate[0] & 0x00008000) > 0) // invisible
                {
                    return(true);
                }
                if (!NativeMethods.IsWindowVisible(hWnd))
                {
                    return(true);
                }
                StringBuilder sb = new StringBuilder(128);

                NativeMethods.GetWindowText(hWnd, sb, 128);
                if (sb.Length == 0)
                {
                    return(true);
                }
                if (sb.ToString() == Text)
                {
                    return(true);
                }
                if (NativeMethods.IsZoomed(hWnd))
                {
                    return(true);
                }
                if (NativeMethods.IsIconic(hWnd))
                {
                    return(true);
                }

                NativeMethods.RECT rect = new NativeMethods.RECT();
                NativeMethods.GetWindowRect(new System.Runtime.InteropServices.HandleRef(this, hWnd), out rect);
                if (rect.Top < collider.Height)
                {
                    return(true);
                }

                CollisionDirection collides = Collisions.CheckCollision(collider, Collisions.GetRectangleFromNative(rect), direction);

                if (collides != CollisionDirection.None && Collisions.isInLimits(collider, Collisions.GetRectangleFromNative(rect), collides))
                {
                    if (!checkTopWindow(collider, rect, hWnd))
                    {
                        collided.Bounds    = Collisions.GetRectangleFromNative(rect);
                        collided.Direction = collides;
                        System.Diagnostics.Debug.WriteLine($"{sb}");
                    }
                }


                return(true);
            }, IntPtr.Zero);

            return(collided);
        }