Ejemplo n.º 1
0
        protected override void OnExplorerAttached() {
            ExplorerHandle = (IntPtr)Explorer.HWND;
            QTUtility.instanceManager.AddButtonBarHandle(ExplorerHandle, Handle);
            dropTargetWrapper = new DropTargetWrapper(this);
            QTTabBarClass tabBar = QTUtility.instanceManager.GetTabBar(ExplorerHandle);

            // If the TabBar and its PluginManager already exist, that means
            // the ButtonBar must have been closed when the Explorer window
            // opened, so we wont' get an initialization message.  Do 
            // initialization now.
            if(fNoSettings || (tabBar != null && tabBar.PluginServerInstance != null)) {
                if(pluginManager == null) {
                    if(tabBar != null) {
                        pluginManager = tabBar.PluginServerInstance;
                        if(pluginManager != null) {
                            pluginManager.AddRef();
                        }
                    }
                    CreateItems(false);
                }
                fNoSettings = false;
            }
        }
Ejemplo n.º 2
0
        protected override void WndProc(ref Message m) {
            int num3 = 0;
            int num4 = 0;
            switch(m.Msg) {
                case WM.INITMENUPOPUP:
                case WM.DRAWITEM:
                case WM.MEASUREITEM:
                    if((iContextMenu2 == null) || !(m.HWnd == Handle)) {
                        goto Label_08F8;
                    }
                    try {
                        iContextMenu2.HandleMenuMsg(m.Msg, m.WParam, m.LParam);
                    }
                    catch {
                    }
                    return;

                case WM.DROPFILES:
                    PInvoke.SendMessage(QTUtility.instanceManager.GetTabBarHandle(ExplorerHandle), 0x233, m.WParam, IntPtr.Zero);
                    return;

                case WM.APP:
                    m.Result = toolStrip.IsHandleCreated ? toolStrip.Handle : IntPtr.Zero;
                    return;

                case WM.COPYDATA: {
                        COPYDATASTRUCT copydatastruct = (COPYDATASTRUCT)Marshal.PtrToStructure(m.LParam, typeof(COPYDATASTRUCT));
                        switch(((int)m.WParam)) {
                            case 1: {
                                    int num = ((int)copydatastruct.dwData) & 0xffff;
                                    int num2 = (((int)copydatastruct.dwData) >> 0x10) & 0xffff;
                                    if((num2 & 1) == 1) {
                                        EnableItemAt(3, (num & 1) == 1);
                                    }
                                    if((num2 & 2) == 2) {
                                        EnableItemAt(4, (num & 2) == 2);
                                    }
                                    if((num2 & 4) == 4) {
                                        EnableItemAt(5, (num & 4) == 4);
                                    }
                                    if((num2 & 8) == 8) {
                                        toolStrip.ShowItemToolTips = (num & 8) == 8;
                                    }
                                    if((num2 & 0x100) == 0x100) {
                                        ClearUserAppsMenu();
                                        CreateItems(false);
                                    }
                                    if((num2 & 0x200) == 0x200) {
                                        ClearUserAppsMenu();
                                    }
                                    return;
                                }
                            case 2:
                                num3 = ((int)copydatastruct.dwData) & 0xffff;
                                num4 = (((int)copydatastruct.dwData) >> 0x10) & 0xffff;
                                if((num4 & 1) == 1) {
                                    EnableItemAt(1, (num3 & 1) == 1);
                                }
                                if((num4 & 2) == 2) {
                                    EnableItemAt(2, (num3 & 2) == 2);
                                }
                                if(((num4 & 1) == 1) || ((num4 & 2) == 2)) {
                                    EnableItemAt(-1, ((num3 & 1) == 1) || ((num3 & 2) == 2));
                                }
                                if((num4 & 4) == 4) {
                                    EnableItemAt(14, (num3 & 4) == 4);
                                }
                                if((num4 & 8) == 8) {
                                    EnableItemAt(15, (num3 & 8) == 8);
                                }
                                if((num4 & 0x10) == 0x10) {
                                    EnableItemAt(12, (num3 & 0x10) == 0x10);
                                }
                                if((num4 & 0x20) == 0x20) {
                                    EnableItemAt(11, (num3 & 0x20) == 0x20);
                                }
                                if((num4 & 0x40) == 0x40) {
                                    foreach(ToolStripItem item in toolStrip.Items) {
                                        if((item.Tag != null) && (((int)item.Tag) == 10)) {
                                            ((ToolStripButton)item).Checked = (num3 & 0x40) == 0x40;
                                            break;
                                        }
                                    }
                                }
                                break;

                            case 3:
                            case 6:
                                return;

                            case 4:
                                if(DoItems((int)copydatastruct.dwData)) {
                                    m.Result = (IntPtr)1;
                                }
                                return;

                            case 5:
                                CreateItems(true);
                                menuLockItem.Checked = LockDropDownItems;
                                RefreshEnabledState(copydatastruct.dwData != IntPtr.Zero);
                                foreach(ToolStripItem item2 in toolStrip.Items) {
                                    if((item2.Tag != null) && (((int)item2.Tag) == 10)) {
                                        ((ToolStripButton)item2).Checked = PInvoke.Ptr_OP_AND(PInvoke.GetWindowLongPtr(ExplorerHandle, -20), 8) == new IntPtr(8);
                                        break;
                                    }
                                }
                                return;

                            case 7:
                                foreach(ToolStripItem item3 in toolStrip.Items) {
                                    if((item3.Tag != null) && (((int)item3.Tag) == 0x13)) {
                                        ((ToolStripTrackBar)item3).SetValueWithoutEvent((int)copydatastruct.dwData);
                                        break;
                                    }
                                }
                                return;

                            case 8:
                                if(searchBox != null) {
                                    searchBox.TextBox.Focus();
                                }
                                return;

                            case 9:
                                // TODO
                                RefreshSearchBox(false);
                                return;

                            case 10:
                                RefreshTexts();
                                return;

                            case 11:
                                if(pluginManager != null) {
                                    string pluginID = Marshal.PtrToStringAuto(copydatastruct.lpData);
                                    for(int i = 0; i < PluginManager.ActivatedButtonsOrder.Count; i++) {
                                        if(pluginID == PluginManager.ActivatedButtonsOrder[i]) {
                                            foreach(ToolStripItem item4 in toolStrip.Items) {
                                                if(((int)item4.Tag) == (0x10000 + i)) {
                                                    Plugin plugin;
                                                    int dwData = (int)copydatastruct.dwData;
                                                    bool flag = (dwData & 1) == 1;
                                                    bool flag2 = (dwData & 2) == 2;
                                                    item4.Enabled = flag;
                                                    if(!pluginManager.TryGetPlugin(pluginID, out plugin)) {
                                                        break;
                                                    }
                                                    IBarButton instance = plugin.Instance as IBarButton;
                                                    if(instance == null) {
                                                        break;
                                                    }
                                                    try {
                                                        item4.ToolTipText = instance.Text;
                                                        if(flag2) {
                                                            item4.Image = instance.GetImage(LargeButton);
                                                        }
                                                        break;
                                                    }
                                                    catch(Exception exception) {
                                                        PluginManager.HandlePluginException(exception, ExplorerHandle, plugin.PluginInformation.Name, "Refreshing plugin image and text.");
                                                        break;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                return;

                            case 12:
                                contextMenu_ItemClicked(null, new ToolStripItemClickedEventArgs(menuCustomize));
                                return;

                            case 13:
                                if((iSearchResultCount > -1) && (iSearchResultCount != ((int)copydatastruct.dwData))) {
                                    RefreshSearchBox(true);
                                }
                                return;

                            case 14:
                                // TODO
                                if(iSearchResultCount > 0) {
                                    iSearchResultCount--;
                                }
                                return;

                            case 15:
                                if(searchBox != null) {
                                    searchBox.Width = SearchBoxWidth;
                                    toolStrip.RaiseOnResize();
                                }
                                return;

                            case 16: {
                                    if(searchBox == null) {
                                        m.Result = (IntPtr)1;
                                        return;
                                    }
                                    string str2 = Marshal.PtrToStringUni(copydatastruct.lpData);
                                    if(str2 == "null") {
                                        str2 = string.Empty;
                                    }
                                    searchBox.Focus();
                                    searchBox.Text = str2;
                                    m.Result = IntPtr.Zero;
                                    return;
                                }
                        }
                        break;
                    }
                case WM.CONTEXTMENU:
                    if((((ddmrGroupButton == null) || !ddmrGroupButton.Visible) && ((ddmrUserAppButton == null) || !ddmrUserAppButton.Visible)) && ((ddmrRecentlyClosed == null) || !ddmrRecentlyClosed.Visible)) {
                        Point p = QTUtility2.PointFromLPARAM(m.LParam);
                        if((p.X == -1) && (p.Y == -1)) {
                            QTUtility2.SendCOPYDATASTRUCT(QTUtility.instanceManager.GetTabBarHandle(ExplorerHandle), (IntPtr)0xffc, "btnCM", (IntPtr)1);
                            return;
                        }
                        if((toolStrip.GetItemAt(toolStrip.PointToClient(p)) != null) || (toolStrip.Items.Count == 0)) {
                            goto Label_08F8;
                        }
                        QTUtility2.SendCOPYDATASTRUCT(QTUtility.instanceManager.GetTabBarHandle(ExplorerHandle), (IntPtr)0xffc, "btnCM", IntPtr.Zero);
                    }
                    return;

                default:
                    goto Label_08F8;
            }
            if((num4 & 0x80) == 0x80) {
                EnableItemAt(0x10, (num3 & 0x80) == 0);
            }
            if(num4 == 0x100) {
                if(pluginManager == null) {
                    QTTabBarClass tabBar = QTUtility.instanceManager.GetTabBar(ExplorerHandle);
                    if(tabBar != null) {
                        pluginManager = tabBar.PluginServerInstance;
                        if(pluginManager != null) {
                            pluginManager.AddRef();
                        }
                    }
                }
                CreateItems(false);
            }
            if((NavDropDown != null) && NavDropDown.Visible) {
                NavDropDown.Close(ToolStripDropDownCloseReason.AppClicked);
            }
            if((ddmrGroupButton != null) && ddmrGroupButton.Visible) {
                ddmrGroupButton.Close(ToolStripDropDownCloseReason.AppClicked);
            }
            if((ddmrRecentlyClosed != null) && ddmrRecentlyClosed.Visible) {
                ddmrRecentlyClosed.Close(ToolStripDropDownCloseReason.AppClicked);
            }
            if((ddmrUserAppButton != null) && ddmrUserAppButton.Visible) {
                ddmrUserAppButton.Close(ToolStripDropDownCloseReason.AppClicked);
            }
            return;
        Label_08F8:
            base.WndProc(ref m);
        }