示例#1
0
        protected override void WndProc(ref Message m)
        {
            try {
                QMenuItem ownerItem;
                if (!fRespondModKeys)
                {
                    base.WndProc(ref m);
                    return;
                }
                int wParam = (int)((long)m.WParam);
                switch (m.Msg)
                {
                case WM.KEYDOWN:
                    break;

                case WM.KEYUP:
                    if (fOnceKeyDown && ((wParam == 0x10) || (wParam == 0x11)))
                    {
                        bool flag2 = false;
                        foreach (QMenuItem item4 in lstQMIResponds.Where(item4 => item4.Selected))
                        {
                            if (item4.Enabled)
                            {
                                Keys modifierKeys = ModifierKeys;
                                if (modifierKeys == Keys.Control)
                                {
                                    item4.ImageKey = "control";
                                }
                                else if (fEnableShiftKey && (modifierKeys == Keys.Shift))
                                {
                                    item4.ImageKey = "shift";
                                }
                                else
                                {
                                    item4.RestoreOriginalImage(fChangeImageSelected, false);
                                }
                                lastKeyImageChangedItem = item4;
                            }
                            flag2 = true;
                            break;
                        }
                        ownerItem = OwnerItem as QMenuItem;
                        if (ownerItem != null)
                        {
                            DropDownMenuBase owner = ownerItem.Owner as DropDownMenuBase;
                            if ((owner != null) && owner.Visible)
                            {
                                if (flag2)
                                {
                                    PInvoke.SendMessage(owner.Handle, 0x2a3, IntPtr.Zero, IntPtr.Zero);
                                }
                                else
                                {
                                    QTUtility2.SendCOPYDATASTRUCT(owner.Handle, (IntPtr)wParam, string.Empty, (IntPtr)1);
                                }
                            }
                        }
                    }
                    goto Label_07C2;

                case WM.MOUSEMOVE:
                    goto Label_0562;

                case WM.MOUSELEAVE:
                    goto Label_072E;

                case WM.PAINT:
                    if (fSuspendPainting)
                    {
                        PInvoke.ValidateRect(m.HWnd, IntPtr.Zero);
                    }
                    else
                    {
                        base.WndProc(ref m);
                    }
                    return;

                case WM.COPYDATA: {
                    COPYDATASTRUCT copydatastruct = (COPYDATASTRUCT)Marshal.PtrToStructure(m.LParam, typeof(COPYDATASTRUCT));
                    ownerItem = GetItemAt(PointToClient(MousePosition)) as QMenuItem;
                    if (!(copydatastruct.dwData == IntPtr.Zero))
                    {
                        goto Label_04B6;
                    }
                    if (ownerItem == null)
                    {
                        goto Label_0462;
                    }
                    Keys keys3 = ModifierKeys;
                    if ((wParam == 0x11) && ((keys3 & Keys.Shift) != Keys.Shift))
                    {
                        ownerItem.ImageKey = "control";
                    }
                    else if ((fEnableShiftKey && (wParam == 0x10)) && ((keys3 & Keys.Control) != Keys.Control))
                    {
                        ownerItem.ImageKey = "shift";
                    }
                    else
                    {
                        ownerItem.RestoreOriginalImage(fChangeImageSelected, false);
                    }
                    lastKeyImageChangedItem = ownerItem;
                    goto Label_07C2;
                }

                default:
                    goto Label_07C2;
                }
                fOnceKeyDown = true;
                if ((((int)((long)m.LParam)) & 0x40000000) == 0)
                {
                    if ((wParam == 0x10) || (wParam == 0x11))
                    {
                        bool flag = false;
                        foreach (QMenuItem item2 in lstQMIResponds.Where(item2 => item2.Selected))
                        {
                            if (item2.Enabled)
                            {
                                Keys keys = ModifierKeys;
                                if ((wParam == 0x11) && ((keys & Keys.Shift) != Keys.Shift))
                                {
                                    item2.ImageKey = "control";
                                }
                                else if ((fEnableShiftKey && (wParam == 0x10)) && ((keys & Keys.Control) != Keys.Control))
                                {
                                    item2.ImageKey = "shift";
                                }
                                else
                                {
                                    item2.RestoreOriginalImage(fChangeImageSelected, false);
                                }
                                lastKeyImageChangedItem = item2;
                            }
                            flag = true;
                            break;
                        }
                        ownerItem = OwnerItem as QMenuItem;
                        if (ownerItem != null)
                        {
                            DropDownMenuBase base2 = ownerItem.Owner as DropDownMenuBase;
                            if ((base2 != null) && base2.Visible)
                            {
                                if (flag)
                                {
                                    PInvoke.SendMessage(base2.Handle, 0x2a3, IntPtr.Zero, IntPtr.Zero);
                                }
                                else
                                {
                                    QTUtility2.SendCOPYDATASTRUCT(base2.Handle, (IntPtr)wParam, string.Empty, IntPtr.Zero);
                                }
                            }
                        }
                    }
                    else if ((wParam == 13) && ((fEnableShiftKey && (ModifierKeys == Keys.Shift)) || (ModifierKeys == Keys.Control)))
                    {
                        foreach (ToolStripItem item3 in Items)
                        {
                            if (item3.Selected)
                            {
                                if (item3.Enabled)
                                {
                                    OnItemClicked(new ToolStripItemClickedEventArgs(item3));
                                }
                                break;
                            }
                        }
                    }
                }
                goto Label_07C2;
Label_0462:
                ownerItem = OwnerItem as QMenuItem;
                if (ownerItem != null)
                {
                    DropDownMenuBase base4 = ownerItem.Owner as DropDownMenuBase;
                    if ((base4 != null) && base4.Visible)
                    {
                        QTUtility2.SendCOPYDATASTRUCT(base4.Handle, (IntPtr)wParam, string.Empty, IntPtr.Zero);
                    }
                }
                goto Label_07C2;
Label_04B6:
                if (ownerItem != null)
                {
                    Keys keys4 = ModifierKeys;
                    if (keys4 == Keys.Control)
                    {
                        ownerItem.ImageKey = "control";
                    }
                    else if (fEnableShiftKey && (keys4 == Keys.Shift))
                    {
                        ownerItem.ImageKey = "shift";
                    }
                    else
                    {
                        ownerItem.RestoreOriginalImage(fChangeImageSelected, false);
                    }
                    lastKeyImageChangedItem = ownerItem;
                }
                else
                {
                    ownerItem = OwnerItem as QMenuItem;
                    if (ownerItem != null)
                    {
                        DropDownMenuBase base5 = ownerItem.Owner as DropDownMenuBase;
                        if ((base5 != null) && base5.Visible)
                        {
                            QTUtility2.SendCOPYDATASTRUCT(base5.Handle, (IntPtr)wParam, string.Empty, (IntPtr)1);
                        }
                    }
                }
                goto Label_07C2;
Label_0562:
                if ((m.WParam == IntPtr.Zero) && (m.LParam == lparamPreviousMouseMove))
                {
                    m.Result = IntPtr.Zero;
                    return;
                }
                lparamPreviousMouseMove = m.LParam;
                if ((!fEnableShiftKey || ((wParam & 4) != 4)) && (((wParam & 8) != 8) && !fChangeImageSelected))
                {
                    goto Label_07C2;
                }
                ToolStripItem itemAt = GetItemAt(QTUtility2.PointFromLPARAM(m.LParam));
                if (itemAt == null)
                {
                    base.WndProc(ref m);
                    return;
                }
                ownerItem = itemAt as QMenuItem;
                if (!IsQmiResponds(ownerItem))
                {
                    goto Label_06F8;
                }
                if (ownerItem == lastMouseActiveItem)
                {
                    goto Label_07C2;
                }
                if (lstQMIResponds.Count > 0x1c)
                {
                    fSuspendPainting = true;
                }
                SuspendLayout();
                if (ownerItem.Enabled)
                {
                    switch (wParam)
                    {
                    case 8:
                        ownerItem.ImageKey = "control";
                        goto Label_06AB;

                    case 4:
                        ownerItem.ImageKey = "shift";
                        goto Label_06AB;
                    }
                    if (((ownerItem.Genre == MenuGenre.Navigation) && (ownerItem.MenuItemArguments != null)) && (!ownerItem.MenuItemArguments.IsBack || (ownerItem.MenuItemArguments.Index != 0)))
                    {
                        ownerItem.ImageKey = ownerItem.MenuItemArguments.IsBack ? "back" : "forward";
                    }
                    else
                    {
                        ownerItem.RestoreOriginalImage();
                    }
                }
Label_06AB:
                if (lastMouseActiveItem != null)
                {
                    lastMouseActiveItem.RestoreOriginalImage();
                }
                if ((ownerItem != lastKeyImageChangedItem) && (lastKeyImageChangedItem != null))
                {
                    lastKeyImageChangedItem.RestoreOriginalImage();
                    lastKeyImageChangedItem = null;
                }
                lastMouseActiveItem = ownerItem;
                fSuspendPainting    = false;
                ResumeLayout(false);
                goto Label_07C2;
Label_06F8:
                if (lastMouseActiveItem != null)
                {
                    lastMouseActiveItem.RestoreOriginalImage();
                    lastMouseActiveItem = null;
                }
                if (lastKeyImageChangedItem != null)
                {
                    lastKeyImageChangedItem.RestoreOriginalImage();
                    lastKeyImageChangedItem = null;
                }
                goto Label_07C2;
Label_072E:
                ResetImageKeys();
                lastMouseActiveItem = null;
            }
            catch (Exception exception) {
                QTUtility2.MakeErrorLog(exception, "MSG:" + m.Msg.ToString("X") + ", WPARAM:" + m.WParam.ToString("X") + ", LPARAM:" + m.LParam.ToString("X"));
            }
Label_07C2:
            base.WndProc(ref m);
            fSuspendPainting = false;
        }
示例#2
0
        protected override void WndProc(ref Message m)
        {
            try {
                QMenuItem ownerItem;
                if(!fRespondModKeys) {
                    base.WndProc(ref m);
                    return;
                }
                int wParam = (int)((long)m.WParam);
                switch(m.Msg) {
                    case WM.KEYDOWN:
                        break;

                    case WM.KEYUP:
                        if(fOnceKeyDown && ((wParam == 0x10) || (wParam == 0x11))) {
                            bool flag2 = false;
                            foreach(QMenuItem item4 in lstQMIResponds.Where(item4 => item4.Selected)) {
                                if(item4.Enabled) {
                                    Keys modifierKeys = ModifierKeys;
                                    if(modifierKeys == Keys.Control) {
                                        item4.ImageKey = "control";
                                    }
                                    else if(fEnableShiftKey && (modifierKeys == Keys.Shift)) {
                                        item4.ImageKey = "shift";
                                    }
                                    else {
                                        item4.RestoreOriginalImage(fChangeImageSelected, false);
                                    }
                                    lastKeyImageChangedItem = item4;
                                }
                                flag2 = true;
                                break;
                            }
                            ownerItem = OwnerItem as QMenuItem;
                            if(ownerItem != null) {
                                DropDownMenuBase owner = ownerItem.Owner as DropDownMenuBase;
                                if((owner != null) && owner.Visible) {
                                    if(flag2) {
                                        PInvoke.SendMessage(owner.Handle, 0x2a3, IntPtr.Zero, IntPtr.Zero);
                                    }
                                    else {
                                        QTUtility2.SendCOPYDATASTRUCT(owner.Handle, (IntPtr)wParam, string.Empty, (IntPtr)1);
                                    }
                                }
                            }
                        }
                        goto Label_07C2;

                    case WM.MOUSEMOVE:
                        goto Label_0562;

                    case WM.MOUSELEAVE:
                        goto Label_072E;

                    case WM.PAINT:
                        if(fSuspendPainting) {
                            PInvoke.ValidateRect(m.HWnd, IntPtr.Zero);
                        }
                        else {
                            base.WndProc(ref m);
                        }
                        return;

                    case WM.COPYDATA: {
                            COPYDATASTRUCT copydatastruct = (COPYDATASTRUCT)Marshal.PtrToStructure(m.LParam, typeof(COPYDATASTRUCT));
                            ownerItem = GetItemAt(PointToClient(MousePosition)) as QMenuItem;
                            if(!(copydatastruct.dwData == IntPtr.Zero)) {
                                goto Label_04B6;
                            }
                            if(ownerItem == null) {
                                goto Label_0462;
                            }
                            Keys keys3 = ModifierKeys;
                            if((wParam == 0x11) && ((keys3 & Keys.Shift) != Keys.Shift)) {
                                ownerItem.ImageKey = "control";
                            }
                            else if((fEnableShiftKey && (wParam == 0x10)) && ((keys3 & Keys.Control) != Keys.Control)) {
                                ownerItem.ImageKey = "shift";
                            }
                            else {
                                ownerItem.RestoreOriginalImage(fChangeImageSelected, false);
                            }
                            lastKeyImageChangedItem = ownerItem;
                            goto Label_07C2;
                        }
                    default:
                        goto Label_07C2;
                }
                fOnceKeyDown = true;
                if((((int)((long)m.LParam)) & 0x40000000) == 0) {
                    if((wParam == 0x10) || (wParam == 0x11)) {
                        bool flag = false;
                        foreach(QMenuItem item2 in lstQMIResponds.Where(item2 => item2.Selected)) {
                            if(item2.Enabled) {
                                Keys keys = ModifierKeys;
                                if((wParam == 0x11) && ((keys & Keys.Shift) != Keys.Shift)) {
                                    item2.ImageKey = "control";
                                }
                                else if((fEnableShiftKey && (wParam == 0x10)) && ((keys & Keys.Control) != Keys.Control)) {
                                    item2.ImageKey = "shift";
                                }
                                else {
                                    item2.RestoreOriginalImage(fChangeImageSelected, false);
                                }
                                lastKeyImageChangedItem = item2;
                            }
                            flag = true;
                            break;
                        }
                        ownerItem = OwnerItem as QMenuItem;
                        if(ownerItem != null) {
                            DropDownMenuBase base2 = ownerItem.Owner as DropDownMenuBase;
                            if((base2 != null) && base2.Visible) {
                                if(flag) {
                                    PInvoke.SendMessage(base2.Handle, 0x2a3, IntPtr.Zero, IntPtr.Zero);
                                }
                                else {
                                    QTUtility2.SendCOPYDATASTRUCT(base2.Handle, (IntPtr)wParam, string.Empty, IntPtr.Zero);
                                }
                            }
                        }
                    }
                    else if((wParam == 13) && ((fEnableShiftKey && (ModifierKeys == Keys.Shift)) || (ModifierKeys == Keys.Control))) {
                        foreach(ToolStripItem item3 in Items) {
                            if(item3.Selected) {
                                if(item3.Enabled) {
                                    OnItemClicked(new ToolStripItemClickedEventArgs(item3));
                                }
                                break;
                            }
                        }
                    }
                }
                goto Label_07C2;
            Label_0462:
                ownerItem = OwnerItem as QMenuItem;
                if(ownerItem != null) {
                    DropDownMenuBase base4 = ownerItem.Owner as DropDownMenuBase;
                    if((base4 != null) && base4.Visible) {
                        QTUtility2.SendCOPYDATASTRUCT(base4.Handle, (IntPtr)wParam, string.Empty, IntPtr.Zero);
                    }
                }
                goto Label_07C2;
            Label_04B6:
                if(ownerItem != null) {
                    Keys keys4 = ModifierKeys;
                    if(keys4 == Keys.Control) {
                        ownerItem.ImageKey = "control";
                    }
                    else if(fEnableShiftKey && (keys4 == Keys.Shift)) {
                        ownerItem.ImageKey = "shift";
                    }
                    else {
                        ownerItem.RestoreOriginalImage(fChangeImageSelected, false);
                    }
                    lastKeyImageChangedItem = ownerItem;
                }
                else {
                    ownerItem = OwnerItem as QMenuItem;
                    if(ownerItem != null) {
                        DropDownMenuBase base5 = ownerItem.Owner as DropDownMenuBase;
                        if((base5 != null) && base5.Visible) {
                            QTUtility2.SendCOPYDATASTRUCT(base5.Handle, (IntPtr)wParam, string.Empty, (IntPtr)1);
                        }
                    }
                }
                goto Label_07C2;
            Label_0562:
                if((m.WParam == IntPtr.Zero) && (m.LParam == lparamPreviousMouseMove)) {
                    m.Result = IntPtr.Zero;
                    return;
                }
                lparamPreviousMouseMove = m.LParam;
                if((!fEnableShiftKey || ((wParam & 4) != 4)) && (((wParam & 8) != 8) && !fChangeImageSelected)) {
                    goto Label_07C2;
                }
                ToolStripItem itemAt = GetItemAt(QTUtility2.PointFromLPARAM(m.LParam));
                if(itemAt == null) {
                    base.WndProc(ref m);
                    return;
                }
                ownerItem = itemAt as QMenuItem;
                if(!IsQmiResponds(ownerItem)) {
                    goto Label_06F8;
                }
                if(ownerItem == lastMouseActiveItem) {
                    goto Label_07C2;
                }
                if(lstQMIResponds.Count > 0x1c) {
                    fSuspendPainting = true;
                }
                SuspendLayout();
                if(ownerItem.Enabled) {
                    switch(wParam) {
                        case 8:
                            ownerItem.ImageKey = "control";
                            goto Label_06AB;

                        case 4:
                            ownerItem.ImageKey = "shift";
                            goto Label_06AB;
                    }
                    if(((ownerItem.Genre == MenuGenre.Navigation) && (ownerItem.MenuItemArguments != null)) && (!ownerItem.MenuItemArguments.IsBack || (ownerItem.MenuItemArguments.Index != 0))) {
                        ownerItem.ImageKey = ownerItem.MenuItemArguments.IsBack ? "back" : "forward";
                    }
                    else {
                        ownerItem.RestoreOriginalImage();
                    }
                }
            Label_06AB:
                if(lastMouseActiveItem != null) {
                    lastMouseActiveItem.RestoreOriginalImage();
                }
                if((ownerItem != lastKeyImageChangedItem) && (lastKeyImageChangedItem != null)) {
                    lastKeyImageChangedItem.RestoreOriginalImage();
                    lastKeyImageChangedItem = null;
                }
                lastMouseActiveItem = ownerItem;
                fSuspendPainting = false;
                ResumeLayout(false);
                goto Label_07C2;
            Label_06F8:
                if(lastMouseActiveItem != null) {
                    lastMouseActiveItem.RestoreOriginalImage();
                    lastMouseActiveItem = null;
                }
                if(lastKeyImageChangedItem != null) {
                    lastKeyImageChangedItem.RestoreOriginalImage();
                    lastKeyImageChangedItem = null;
                }
                goto Label_07C2;
            Label_072E:
                ResetImageKeys();
                lastMouseActiveItem = null;
            }
            catch(Exception exception) {
                QTUtility2.MakeErrorLog(exception, "MSG:" + m.Msg.ToString("X") + ", WPARAM:" + m.WParam.ToString("X") + ", LPARAM:" + m.LParam.ToString("X"));
            }
            Label_07C2:
            base.WndProc(ref m);
            fSuspendPainting = false;
        }
示例#3
0
        protected override void OnPreviewKeyDown(PreviewKeyDownEventArgs e)
        {
            if (!fRespondModKeys)
            {
                base.OnPreviewKeyDown(e);
                return;
            }
            if (((fEnableShiftKey && e.Shift) || (e.Control || fChangeImageSelected)) && ((e.KeyCode == Keys.Down) || (e.KeyCode == Keys.Up)))
            {
                SuspendLayout();
                try {
                    int           index;
                    ToolStripItem item = Items.Cast <ToolStripItem>().FirstOrDefault(item2 => item2.Selected);
                    if (item != null)
                    {
                        QMenuItem item3 = item as QMenuItem;
                        if (item3 != null)
                        {
                            if ((item3.Genre == MenuGenre.Application) || (item3.Genre == MenuGenre.RecentFile))
                            {
                                base.OnPreviewKeyDown(e);
                                return;
                            }
                            item3.RestoreOriginalImage();
                        }
                        index = Items.IndexOf(item);
                    }
                    else if (e.KeyCode == Keys.Down)
                    {
                        index = Items.Count - 1;
                    }
                    else
                    {
                        index = 0;
                    }
                    if (index != -1)
                    {
                        int num2;
                        if (e.KeyCode == Keys.Down)
                        {
                            if (index == (Items.Count - 1))
                            {
                                num2 = 0;
                            }
                            else
                            {
                                num2 = index + 1;
                            }
                            for (int i = 0; (Items[num2] is ToolStripSeparator) && (i < Items.Count); i++)
                            {
                                if (num2 == (Items.Count - 1))
                                {
                                    num2 = 0;
                                }
                                else
                                {
                                    num2++;
                                }
                            }
                        }
                        else
                        {
                            if (index == 0)
                            {
                                num2 = Items.Count - 1;
                            }
                            else
                            {
                                num2 = index - 1;
                            }
                            for (int j = 0; (Items[num2] is ToolStripSeparator) && (j < Items.Count); j++)
                            {
                                if (num2 == 0)
                                {
                                    num2 = Items.Count - 1;
                                }
                                else
                                {
                                    num2--;
                                }
                            }
                        }
                        if (Items[num2].Enabled)
                        {
                            QMenuItem item4 = Items[num2] as QMenuItem;
                            if (((item4 != null) && (item4.Genre != MenuGenre.Application)) && (item4.Target == MenuTarget.Folder))
                            {
                                switch (ModifierKeys)
                                {
                                case Keys.Control:
                                    item4.ImageKey = "control";
                                    goto Label_0254;

                                case Keys.Shift:
                                    item4.ImageKey = "shift";
                                    goto Label_0254;
                                }
                                item4.RestoreOriginalImage(false, item4.Genre == MenuGenre.Navigation);
                            }
                        }
                    }
                }
                finally {
                    ResumeLayout(false);
                }
            }
Label_0254:
            base.OnPreviewKeyDown(e);
        }