Exemplo n.º 1
0
        private static User.LowLevelKeyboardDelegate hDelegate; //The Hook Delegate

        /// <summary> SetValues()
        /// Sets the Values of all Attributes to there Start-Up value
        /// </summary>
        /// <returns>true</returns>
        private static bool SetValues()
        {
            cHandle = Kernel.GetConsoleWindow();
            visible = true;
            Hide();

            Process me = Process.GetCurrentProcess();

            safteyOn = false;
            mHandle  = Kernel.GetModuleHandle(me.MainModule.ModuleName);
            pHandle  = me.Id;

            hHandle  = IntPtr.Zero;
            mhHandle = IntPtr.Zero;
            position = new FourPoint(0, 0, 0, 0);

            state     = BaltoState.Starting;
            swapSave  = new FourPoint(false);
            bind      = Binds.ControlFreak;
            hDelegate = HookCallback;

            deckApps = new Deck[0];
            freeApps = new APPDAT[0];
            myWindow = new BaltoGUI();

            myWindow.Create();
            UpdateData();
            Update();

            myWindow.Hide();
            return(true);
        }
Exemplo n.º 2
0
        /// <summary> DrawRow1b(Graphics, int, ref FourPoint, ref FourPoint, Object)
        /// The Swap-State draw method.
        /// Detects the state it should be in and draws the correct form of Row1
        /// </summary>
        /// <param name="graphic">The graphic object used to draw</param>
        /// <param name="length">The number of decks to draw</param>
        /// <param name="cur">the current position</param>
        /// <param name="sav">the saved position for swapping</param>
        /// <param name="img">the saved icon to draw</param>
        internal void DrawRow1b(Graphics graphic, int length, ref FourPoint cur, ref FourPoint sav, Color bgColor, Object img = null)
        {
            int count = 3;

            int  LeftX;
            int  RightX;
            bool LeftCheck;
            bool RightCheck;

            if (sav.Y == 1)
            {
                for (int i = 0; i < count; i++)
                {
                    LeftX      = cur.X1 - count + i;
                    RightX     = cur.X1 + count - i;
                    LeftCheck  = cur.X1 - sav.X1 - count + i >= 0;
                    RightCheck = sav.X1 - cur.X1 - count + i >= 0;
                    if (LeftCheck)
                    {
                        if (LeftX + 1 >= 0)
                        {
                            graphic.DrawImage(deckImg, new Point(55 + 55 * i, iconY1 - 9));
                        }
                    }
                    else if (LeftX >= 0)
                    {
                        graphic.DrawImage(deckImg, new Point(55 + 55 * i, iconY1 - 9));
                    }
                    if (RightCheck)
                    {
                        if (RightX - 1 < length)
                        {
                            graphic.DrawImage(deckImg, new Point(400 - (55 * i), iconY1 - 9));
                        }
                        else if (RightX - 1 == length)
                        {
                            graphic.DrawImage(plusImg, new Point(400 - (55 * i), iconY1 - 9));
                        }
                    }
                    else if (RightX < length)
                    {
                        graphic.DrawImage(deckImg, new Point(400 - (55 * i), iconY1 - 9));
                    }
                    else if (RightX == length)
                    {
                        graphic.DrawImage(plusImg, new Point(400 - (55 * i), iconY1 - 9));
                    }
                }
                graphic.DrawImage((Image)img, new Rectangle(234, iconY1, 32, 32));
            }
            else
            {
                DrawRow1(graphic, length, cur.X1);
                if (cur.Y == 1 && img != null)
                {
                    DrawIcon(graphic, (Icon)img, bgColor, 234, iconY1);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary> Update(APPDAT[], APPDAT[], ref FourPoint, ref FourPoint)
        /// ReDraws and Updates the GUI window.
        /// </summary>
        /// <param name="free">The APPDAT[] used to draw Row0</param>
        /// <param name="decks">The APPDAT[][] used to draw Row1 and Row2</param>
        /// <returns></returns>
        internal bool Update(APPDAT[] free, Deck[] decks, ref FourPoint position, ref FourPoint swaPosition)
        {
            // Draw the GUI
            Bitmap bitmap1 = new Bitmap(this.size.Width, this.size.Height, PixelFormat.Format32bppArgb);

            using (Graphics graphics1 = Graphics.FromImage(bitmap1))
            {
                this.Draw(graphics1, free, decks, ref position, ref swaPosition);
            }
            //Update the GUI-Window
            Rectangle     rectangle1;
            SIZE          size1;
            POINT         point1;
            POINT         point2;
            BLENDFUNCTION blendfunction1;

            rectangle1 = new Rectangle(0, 0, this.size.Width, this.size.Height);
            IntPtr ptr1 = User.GetDC(IntPtr.Zero);
            IntPtr ptr2 = Gdi.CreateCompatibleDC(ptr1);
            IntPtr ptr3 = bitmap1.GetHbitmap(Color.FromArgb(0));
            IntPtr ptr4 = Gdi.SelectObject(ptr2, ptr3);

            size1.cx                           = this.size.Width;
            size1.cy                           = this.size.Height;
            point1.x                           = this.location.X;
            point1.y                           = this.location.Y;
            point2.x                           = 0;
            point2.y                           = 0;
            blendfunction1                     = new BLENDFUNCTION();
            blendfunction1.BlendOp             = 0;
            blendfunction1.BlendFlags          = 0;
            blendfunction1.SourceConstantAlpha = 255;
            blendfunction1.AlphaFormat         = 1;

            User.UpdateLayeredWindow(base.Handle, ptr1, ref point1, ref size1, ptr2, ref point2, 0, ref blendfunction1, 2); //2=ULW_ALPHA
            Gdi.SelectObject(ptr2, ptr4);
            User.ReleaseDC(IntPtr.Zero, ptr1);
            Gdi.DeleteObject(ptr3);
            Gdi.DeleteDC(ptr2);
            return(true);
        }
Exemplo n.º 4
0
        /// <summary> DrawRow2b(Graphics, APPDAT[], ref FourPoint, ref FourPoint, int, Object)
        /// The Swap-State draw method.
        /// Detects the state it should be in and draws the correct form of Row2
        /// </summary>
        /// <param name="graphic">The graphic object used to draw</param>
        /// <param name="apps">The APPDAT[] being drawn as row0</param>
        /// <param name="cur">The Current position</param>
        /// <param name="sav">The saved position for swap</param>
        /// <param name="count">The number of icons to draw on each side of the focus</param>
        /// <param name="img">The saved icon to draw</param>
        internal void DrawRow2b(Graphics graphic, APPDAT[] apps, ref FourPoint cur, ref FourPoint sav, int count, Color bgColor, Object img = null)
        {
            int avg    = (this.size.Width / 2 - 109) / count;
            int buffer = 75;

            int  LeftX;
            int  RightX;
            bool LeftCheck;
            bool RightCheck;

            if (sav.Y == 2 && cur.X1 == sav.X1) //swapping within same deck
            {
                Console.Write("\n");
                for (int i = 0; i < count; i++)
                {
                    LeftX      = cur.X2 - count + i;
                    RightX     = cur.X2 + count - i;
                    LeftCheck  = cur.X2 - sav.X2 - count + i >= 0; //on the left of save
                    RightCheck = sav.X2 - cur.X2 - count + i >= 0; //on the right of save
                    if (LeftCheck)
                    {
                        if (LeftX + 1 >= 0)
                        {
                            DrawIcon(graphic, apps[LeftX + 1].icon, apps[LeftX + 1].iconBG, buffer + avg - (count - i) * 2, iconY2);
                        }
                    }
                    else if (LeftX >= 0)
                    {
                        DrawIcon(graphic, apps[LeftX].icon, apps[LeftX].iconBG, buffer + avg - (count - i) * 2, iconY2);
                    }
                    if (RightCheck)
                    {
                        if (RightX - 1 >= 0)
                        {
                            DrawIcon(graphic, apps[RightX - 1].icon, apps[RightX - 1].iconBG, this.size.Width - 16 - buffer - avg + (count - i) * 2, iconY2);
                        }
                    }
                    else if (RightX < apps.Length)
                    {
                        DrawIcon(graphic, apps[RightX].icon, apps[RightX].iconBG, this.size.Width - 16 - buffer - avg + (count - i) * 2, iconY2);
                    }
                    buffer += (avg - (count - i));
                }
                DrawIcon(graphic, (Icon)img, bgColor, 234, iconY2);
            }
            else if (cur.Y == 2)
            {
                Console.Write("\n");
                for (int i = 0; i < count; i++)
                {
                    LeftX  = cur.X2 - count + i;
                    RightX = cur.X2 + count - i;
                    if (LeftX >= 0)
                    {
                        DrawIcon(graphic, apps[LeftX].icon, apps[LeftX].iconBG, buffer + avg - (count - i) * 2, iconY2);
                    }
                    if (RightX - 1 < apps.Length)
                    {
                        DrawIcon(graphic, apps[RightX - 1].icon, apps[RightX - 1].iconBG, this.size.Width - 16 - buffer - avg + (count - i) * 2, iconY2);
                    }
                    buffer += (avg - (count - i));
                }
                if (sav.Y == 1)
                {
                    graphic.DrawImage((Image)img, new Rectangle(234, iconY2, 32, 32));
                }
                else
                {
                    DrawIcon(graphic, (Icon)img, bgColor, 234, iconY2);
                }
            }
            else
            {
                DrawRow2(graphic, apps, cur.X2, count);
            }
        }
Exemplo n.º 5
0
        /// <summary> DrawRow0b(Graphics, APPDAT[], ref FourPoint, ref FourPoint, int, Object)
        /// The Swap-State draw method.
        /// Detects the state it should be in and draws the correct form of Row0
        /// </summary>
        /// <param name="graphic">The graphic object used to draw</param>
        /// <param name="apps">The APPDAT[] being drawn as row0</param>
        /// <param name="cur">The Current position</param>
        /// <param name="sav">The saved position for swap</param>
        /// <param name="count">The number of icons to draw on each side of the focus</param>
        /// <param name="img">The saved icon to draw given as an object</param>
        internal void DrawRow0b(Graphics graphic, APPDAT[] apps, ref FourPoint cur, ref FourPoint sav, int count, Color bgColor, Object img = null)
        {
            int avg    = (this.size.Width / 2 - 109) / count;
            int buffer = 75;

            int  LeftX;
            int  RightX;
            bool LeftCheck;
            bool RightCheck;

            if (sav.Y == 0)
            {
                for (int i = 0; i < count; i++)
                {
                    LeftX      = cur.X0 - count + i;
                    RightX     = cur.X0 + count - i;
                    LeftCheck  = cur.X0 - sav.X0 - count + i >= 0;
                    RightCheck = sav.X0 - cur.X0 - count + i >= 0;
                    if (LeftCheck)
                    {
                        if (LeftX + 1 >= 0)
                        {
                            DrawIcon(graphic, apps[LeftX + 1].icon, apps[LeftX + 1].iconBG, buffer + avg - (count - i) * 2, iconY0);
                        }
                    }
                    else if (LeftX >= 0)
                    {
                        DrawIcon(graphic, apps[LeftX].icon, apps[LeftX].iconBG, buffer + avg - (count - i) * 2, iconY0);
                    }
                    if (RightCheck)
                    {
                        if (RightX - 1 >= 0)
                        {
                            DrawIcon(graphic, apps[RightX - 1].icon, apps[RightX - 1].iconBG, this.size.Width - 16 - buffer - avg + (count - i) * 2, iconY0);
                        }
                    }
                    else if (RightX < apps.Length)
                    {
                        DrawIcon(graphic, apps[RightX].icon, apps[RightX].iconBG, this.size.Width - 16 - buffer - avg + (count - i) * 2, iconY0);
                    }
                    buffer += (avg - (count - i));
                }
                DrawIcon(graphic, (Icon)img, bgColor, 234, iconY0);
            }
            else if (cur.Y == 0)
            {
                for (int i = 0; i < count; i++)
                {
                    LeftX  = cur.X0 - count + i;
                    RightX = cur.X0 + count - i;
                    if (LeftX >= 0)
                    {
                        DrawIcon(graphic, apps[LeftX].icon, apps[LeftX].iconBG, buffer + avg - (count - i) * 2, iconY0);
                    }
                    if (RightX - 1 < apps.Length)
                    {
                        DrawIcon(graphic, apps[RightX - 1].icon, apps[RightX - 1].iconBG, this.size.Width - 16 - buffer - avg + (count - i) * 2, iconY0);
                    }
                    buffer += (avg - (count - i));
                }
                if (sav.Y == 1)
                {
                    graphic.DrawImage((Image)img, new Point(225, 125));             /*WAYPOINT 1*/
                }
                else
                {
                    DrawIcon(graphic, (Icon)img, bgColor, 234, iconY0);
                }
            }
            else
            {
                DrawRow0(graphic, apps, cur.X0, count);
            }
        }
Exemplo n.º 6
0
        /// <summary> Draw(Graphics, APPDAT[], APPDAT[], ref FourPoing, ref FourPoint)
        /// Redraws the GUI using data from the console.
        /// </summary>
        /// <param name="graphic"> The graphic object being used to draw the GUI</param>
        /// <param name="free"> The APPDAT[] representing the Free-Apps.</param>
        /// <param name="decks"> The APPDAT[][] representing the Decked-Apps</param>
        /// <param name="position"> The FourPoint used to represent the cursor position</param>
        /// <param name="saved"> The FourPoint used to tell the cursor position at swap-call</param>
        internal void Draw(Graphics graphic, APPDAT[] free, Deck[] decks, ref FourPoint position, ref FourPoint saved)
        {
            bool DrawDeck = position.X1 != decks.Length;

            APPDAT[] CrntDeck;
            if (DrawDeck)
            {
                CrntDeck = decks[position.X1].apps;
            }
            else
            {
                CrntDeck = new APPDAT[0];
            }

            GraphicsPath path = new GraphicsPath();

            //Paint BG, should cover up anything that used to be there.
            graphic.DrawImage(this.bgImage, new Point(0, 0));
            switch (state)
            {
            //Default Case is so straight forward.
            case GUIstate.Default:
                DrawRow0(graphic, free, position.X0, count);
                DrawRow1(graphic, decks.Length, position.X1);
                if (DrawDeck)
                {
                    DrawRow2(graphic, CrntDeck, position.X2, count);
                }
                DrawCursor(graphic, Color.Black, position.Y);
                break;

            //Unlike the swapping case, which is radically different in a million ways, and looks like the ugliest code ever.
            case GUIstate.Swapping:
                Color theBG = Color.Transparent;
                switch (saved.Y)
                {
                case 0:
                    theBG = free[saved.X0].iconBG;
                    DrawRow0b(graphic, free, ref position, ref saved, count, theBG, free[saved.X0].icon);
                    DrawRow1b(graphic, decks.Length, ref position, ref saved, theBG, free[saved.X0].icon);
                    if (DrawDeck)
                    {
                        DrawRow2b(graphic, CrntDeck, ref position, ref saved, count, theBG, free[saved.X0].icon);
                    }
                    break;

                case 1:
                    DrawRow0b(graphic, free, ref position, ref saved, count, theBG, deckImg);
                    DrawRow1b(graphic, decks.Length, ref position, ref saved, theBG, deckImg);
                    if (DrawDeck)
                    {
                        DrawRow2b(graphic, CrntDeck, ref position, ref saved, count, theBG, deckImg);
                    }
                    break;

                case 2:
                    theBG = decks[saved.X1].apps[saved.X2].iconBG;
                    DrawRow0b(graphic, free, ref position, ref saved, count, theBG, decks[saved.X1].apps[saved.X2].icon);
                    DrawRow1b(graphic, decks.Length, ref position, ref saved, theBG, decks[saved.X1].apps[saved.X2].icon);
                    if (DrawDeck)
                    {
                        DrawRow2b(graphic, CrntDeck, ref position, ref saved, count, theBG, decks[saved.X1].apps[saved.X2].icon);
                    }
                    break;
                }
                DrawCursor(graphic, Color.Blue, position.Y);
                break;
            }
            if (this.state == GUIstate.Default)
            {
                switch (position.Y)
                {
                case 0:
                    DrawWindowText(graphic, free[position.X0].windowText, Color.Black);
                    break;

                case 1:
                    if (position.X1 == decks.Length)
                    {
                        DrawWindowText(graphic, "New Deck", Color.Black);
                    }
                    else
                    {
                        DrawWindowText(graphic, "Deck", Color.Black);
                    }
                    break;

                case 2:
                    DrawWindowText(graphic, decks[position.X1].apps[position.X2].windowText, Color.Black);
                    break;
                }
            }
            else if (this.state == GUIstate.Swapping)
            {
                switch (saved.Y)
                {
                case 0:
                    DrawWindowText(graphic, free[saved.X0].windowText, Color.Black);
                    break;

                case 1:
                    DrawWindowText(graphic, "Deck", Color.Black);
                    break;

                case 2:
                    DrawWindowText(graphic, decks[saved.X1].apps[saved.X2].windowText, Color.Black);
                    break;
                }
            }
        }