Пример #1
0
 private bool ShowThumbnailTooltip(IntPtr pIDL, int iItem, IntPtr hwndListView, bool fKey) {
     StringBuilder pszPath = new StringBuilder(260);
     if(PInvoke.SHGetPathFromIDList(pIDL, pszPath)) {
         string path = pszPath.ToString();
         if(File.Exists(path)) {
             if((path.StartsWith("::") || path.StartsWith(@"\\")) || path.ToLower().StartsWith(@"a:\")) {
                 return false;
             }
             string ext = Path.GetExtension(path).ToLower();
             if(ext == ".lnk") {
                 path = ShellMethods.GetLinkTargetPath(path);
                 if(path.Length == 0) {
                     return false;
                 }
                 ext = Path.GetExtension(path).ToLower();
             }
             if(ThumbnailTooltipForm.ExtIsSupported(ext)) {
                 if(this.thumbnailTooltip == null) {
                     this.thumbnailTooltip = new ThumbnailTooltipForm();
                     this.thumbnailTooltip.ThumbnailVisibleChanged += new QEventHandler(this.thumbnailTooltip_ThumbnailVisibleChanged);
                     this.timer_Thumbnail = new System.Windows.Forms.Timer(this.components);
                     this.timer_Thumbnail.Interval = 400;
                     this.timer_Thumbnail.Tick += new EventHandler(this.timer_Thumbnail_Tick);
                 }
                 if(this.thumbnailTooltip.IsShownByKey && !fKey) {
                     this.thumbnailTooltip.IsShownByKey = false;
                     return true;
                 }
                 this.thumbnailIndex = iItem;
                 this.thumbnailTooltip.IsShownByKey = fKey;
                 // TODO
                 // QTTabBarLib.Interop.RECT rect = QTTabBarClass.GetLVITEMRECT(hwndListView, iItem, false, 0);
                 QTTabBarLib.Interop.RECT rect = new QTTabBarLib.Interop.RECT();
                 return this.thumbnailTooltip.ShowToolTip(path, new Point(rect.right - 0x10, rect.bottom - 8));
             }
         }
     }
     this.HideThumbnailTooltip();
     return false;
 }
Пример #2
0
 private bool ShowSubDirTip(IntPtr pIDL, int iItem, IntPtr hwndListView, bool fSkipFocusCheck) {
     if(fSkipFocusCheck || (this.hwndListView == PInvoke.GetFocus())) {
         try {
             string displayName = ShellMethods.GetDisplayName(pIDL, false);
             if(!QTTabBarClass.TryMakeSubDirTipPath(ref displayName)) {
                 return false;
             }
             int pViewMode = 1;
             this.folderView.GetCurrentViewMode(ref pViewMode);
             // TODO
             // QTTabBarLib.Interop.RECT rect = QTTabBarClass.GetLVITEMRECT(hwndListView, iItem, true, pViewMode);
             QTTabBarLib.Interop.RECT rect = new QTTabBarLib.Interop.RECT();
             Point pnt = new Point(rect.right - 0x10, rect.bottom - 0x10);
             if(this.subDirTip == null) {
                 this.subDirTip = new SubDirTipForm(this.ThisHandle, this.hwndListView, false, null); // TODO
                 this.subDirTip.MenuItemClicked += new ToolStripItemClickedEventHandler(this.subDirTip_MenuItemClicked);
                 this.subDirTip.MultipleMenuItemsClicked += new EventHandler(this.subDirTip_MultipleMenuItemsClicked);
                 this.subDirTip.MenuItemRightClicked += new ItemRightClickedEventHandler(this.subDirTip_MenuItemRightClicked);
                 this.subDirTip.MultipleMenuItemsRightClicked += new ItemRightClickedEventHandler(this.subDirTip_MultipleMenuItemsRightClicked);
             }
             byte[] idl = null;
             if(QTUtility.IsVista && string.Equals(displayName, IDLWrapper.PATH_USERSFILES, StringComparison.OrdinalIgnoreCase)) {
                 idl = ShellMethods.GetIDLData(pIDL);
             }
             // TODO
             // this.subDirTip.ShowSubDirTip(displayName, idl, pnt, hwndListView);
             return true;
         }
         catch(Exception exception) {
             QTUtility2.MakeErrorLog(exception, null);
         }
     }
     return false;
 }
Пример #3
0
        private static void DrawTextOnGlass(IntPtr hDC, string text, Font font, Rectangle rct, int iGlowSize, StringAlignment horizontalAlign)
        {
            QTTabBarLib.Interop.RECT rect  = new QTTabBarLib.Interop.RECT();
            QTTabBarLib.Interop.RECT pRect = new QTTabBarLib.Interop.RECT();
            rect.left    = rct.Left;
            rect.right   = rct.Right + (4 * iGlowSize);
            rect.top     = rct.Top;
            rect.bottom  = rct.Bottom + (2 * iGlowSize);
            pRect.left   = 2 * iGlowSize;
            pRect.top    = 2;
            pRect.right  = rect.Width - (3 * iGlowSize);
            pRect.bottom = rect.Height - 2;
            TextFormatFlags dwFlags = TextFormatFlags.ModifyString | TextFormatFlags.NoPrefix | TextFormatFlags.SingleLine;

            switch (horizontalAlign)
            {
            case StringAlignment.Near:
                dwFlags |= TextFormatFlags.EndEllipsis;
                break;

            case StringAlignment.Center:
                dwFlags |= TextFormatFlags.PathEllipsis | TextFormatFlags.HorizontalCenter;
                break;

            case StringAlignment.Far:
                dwFlags |= TextFormatFlags.Right;
                break;
            }
            IntPtr ptr = PInvoke.CreateCompatibleDC(hDC);

            if (ptr != IntPtr.Zero)
            {
                IntPtr ptr5;
                QTTabBarLib.Interop.BITMAPINFO pbmi = new QTTabBarLib.Interop.BITMAPINFO();
                pbmi.bmiHeader.biSize        = Marshal.SizeOf(typeof(QTTabBarLib.Interop.BITMAPINFOHEADER));
                pbmi.bmiHeader.biWidth       = rect.Width;
                pbmi.bmiHeader.biHeight      = -rect.Height;
                pbmi.bmiHeader.biPlanes      = 1;
                pbmi.bmiHeader.biBitCount    = 0x20;
                pbmi.bmiHeader.biCompression = 0;
                IntPtr hgdiobj = PInvoke.CreateDIBSection(ptr, ref pbmi, 0, out ptr5, IntPtr.Zero, 0);
                if (hgdiobj != IntPtr.Zero)
                {
                    IntPtr ptr3 = PInvoke.SelectObject(ptr, hgdiobj);
                    IntPtr ptr6 = font.ToHfont();
                    IntPtr ptr4 = PInvoke.SelectObject(ptr, ptr6);
                    VisualStyleRenderer renderer = new VisualStyleRenderer(VisualStyleElement.Window.Caption.Active);
                    DTTOPTS             pOptions = new DTTOPTS();
                    pOptions.dwSize    = Marshal.SizeOf(typeof(DTTOPTS));
                    pOptions.dwFlags   = 0x2800;
                    pOptions.iGlowSize = iGlowSize;
                    PInvoke.DrawThemeTextEx(renderer.Handle, ptr, 0, 0, text, -1, dwFlags, ref pRect, ref pOptions);
                    PInvoke.BitBlt(hDC, rect.left, rect.top, rect.Width, rect.Height, ptr, 0, 0, 0xcc0020);
                    PInvoke.SelectObject(ptr, ptr3);
                    PInvoke.SelectObject(ptr, ptr4);
                    PInvoke.DeleteObject(hgdiobj);
                    PInvoke.DeleteObject(ptr6);
                }
                PInvoke.DeleteDC(ptr);
            }
        }
Пример #4
0
        private bool shellViewController_MessageCaptured(ref Message msg) {
            QTTabBarLib.Interop.NMHDR nmhdr;
            if(msg.Msg == WM.NOTIFY) {
                nmhdr = (QTTabBarLib.Interop.NMHDR)Marshal.PtrToStructure(msg.LParam, typeof(QTTabBarLib.Interop.NMHDR));
                if(nmhdr.hwndFrom != this.shellViewController.OptionalHandle) {
                    return false;
                }
                if(this.folderView == null) {
                    return false;
                }
                switch(nmhdr.code) {
                    case -103:
                        if(!QTUtility.CheckConfig(Settings.NoShowSubDirTips)) {
                            this.HideSubDirTip();
                        }
                        goto Label_057E;

                    case -102:
                        goto Label_057E;

                    case -101:
                        if(!QTUtility.CheckConfig(Settings.NoShowSubDirTips)) {
                            QTTabBarLib.Interop.NMLISTVIEW nmlistview = (QTTabBarLib.Interop.NMLISTVIEW)Marshal.PtrToStructure(msg.LParam, typeof(QTTabBarLib.Interop.NMLISTVIEW));
                            if(nmlistview.uChanged == 8) {
                                uint num = nmlistview.uNewState & 8;
                                uint num2 = nmlistview.uOldState & 8;
                                if((nmlistview.iItem != this.itemIndexDROPHILITED) && (num2 != num)) {
                                    if(num != 0) {
                                        this.HandleDROPHILITED(nmlistview.iItem, nmhdr.hwndFrom);
                                    }
                                    else {
                                        this.HandleDROPHILITED(-1, IntPtr.Zero);
                                    }
                                }
                            }
                        }
                        goto Label_057E;

                    case -8:
                        this.HideThumbnailTooltip();
                        this.HideSubDirTip_DesktopInactivated();
                        goto Label_057E;

                    case -114: {
                            NMITEMACTIVATE nmitemactivate = (NMITEMACTIVATE)Marshal.PtrToStructure(msg.LParam, typeof(NMITEMACTIVATE));
                            bool fEnqExec = !QTUtility.CheckConfig(Settings.NoRecentFiles);
                            Keys modKey = ((((nmitemactivate.uKeyFlags & 1) == 1) ? Keys.Alt : Keys.None) | (((nmitemactivate.uKeyFlags & 2) == 2) ? Keys.Control : Keys.None)) | (((nmitemactivate.uKeyFlags & 4) == 4) ? Keys.Shift : Keys.None);
                            return this.HandleTabFolderActions(-1, modKey, fEnqExec);
                        }
                    case -175:
                        if(!QTUtility.IsVista && !QTUtility.CheckConfig(Settings.ExtWhileRenaming)) {
                            this.shellViewController.DefWndProc(ref msg);
                            if(msg.Result == IntPtr.Zero) {
                                QTTabBarLib.Interop.NMLVDISPINFO nmlvdispinfo = (QTTabBarLib.Interop.NMLVDISPINFO)Marshal.PtrToStructure(msg.LParam, typeof(QTTabBarLib.Interop.NMLVDISPINFO));
                                // TODO
                                // QTTabBarClass.HandleRenaming(this.hwndListView, nmlvdispinfo.item.lParam, this);
                            }
                        }
                        goto Label_057E;

                    case -158: {
                            if(!QTUtility.CheckConfig(Settings.ShowTooltipPreviews) || !(!QTUtility.CheckConfig(Settings.PreviewsWithShift) ^ (Control.ModifierKeys == Keys.Shift))) {
                                goto Label_057E;
                            }
                            QTTabBarLib.Interop.NMLVGETINFOTIP nmlvgetinfotip = (QTTabBarLib.Interop.NMLVGETINFOTIP)Marshal.PtrToStructure(msg.LParam, typeof(QTTabBarLib.Interop.NMLVGETINFOTIP));
                            IntPtr zero = IntPtr.Zero;
                            try {
                                if((this.folderView.Item(nmlvgetinfotip.iItem, out zero) != 0) || !(zero != IntPtr.Zero)) {
                                    goto Label_057E;
                                }
                                if(((this.thumbnailTooltip != null) && this.thumbnailTooltip.IsShowing) && (nmlvgetinfotip.iItem == this.thumbnailIndex)) {
                                    return true;
                                }
                                if((this.timer_HoverThumbnail != null) && this.timer_HoverThumbnail.Enabled) {
                                    return true;
                                }
                                // TODO
                                // QTTabBarLib.Interop.RECT lprc = QTTabBarClass.GetLVITEMRECT(nmhdr.hwndFrom, nmlvgetinfotip.iItem, false, 0);
                                QTTabBarLib.Interop.RECT lprc = new QTTabBarLib.Interop.RECT();
                                Point mousePosition = Control.MousePosition;
                                return this.ShowThumbnailTooltip(zero, nmlvgetinfotip.iItem, nmhdr.hwndFrom, !PInvoke.PtInRect(ref lprc, new BandObjectLib.POINT(mousePosition)));
                            }
                            finally {
                                if(zero != IntPtr.Zero) {
                                    PInvoke.CoTaskMemFree(zero);
                                }
                            }
                            //goto Label_0264;
                        }
                    case -121:
                        goto Label_0264;
                }
            }
            goto Label_057E;
        Label_0264:
            if(QTUtility.CheckConfig(Settings.ShowTooltipPreviews) || !QTUtility.CheckConfig(Settings.NoShowSubDirTips)) {
                QTTabBarLib.Interop.NMLISTVIEW nmlistview2 = (QTTabBarLib.Interop.NMLISTVIEW)Marshal.PtrToStructure(msg.LParam, typeof(QTTabBarLib.Interop.NMLISTVIEW));
                Keys modifierKeys = Control.ModifierKeys;
                if(QTUtility.CheckConfig(Settings.ShowTooltipPreviews)) {
                    if(this.timer_HoverThumbnail == null) {
                        this.timer_HoverThumbnail = new System.Windows.Forms.Timer(this.components);
                        this.timer_HoverThumbnail.Interval = (int)(SystemInformation.MouseHoverTime * 0.2);
                        this.timer_HoverThumbnail.Tick += new EventHandler(this.timer_HoverThumbnail_Tick);
                    }
                    this.timer_HoverThumbnail.Enabled = false;
                    this.timer_HoverThumbnail.Enabled = true;
                    if(((this.thumbnailTooltip != null) && (this.thumbnailTooltip.IsShowing || this.fThumbnailPending)) && (nmlistview2.iItem != this.thumbnailIndex)) {
                        if(!QTUtility.CheckConfig(Settings.PreviewsWithShift) ^ (modifierKeys == Keys.Shift)) {
                            if(nmlistview2.iItem > -1) {
                                IntPtr ppidl = IntPtr.Zero;
                                try {
                                    if(((this.folderView.Item(nmlistview2.iItem, out ppidl) == 0) && (ppidl != IntPtr.Zero)) && this.ShowThumbnailTooltip(ppidl, nmlistview2.iItem, nmhdr.hwndFrom, false)) {
                                        return false;
                                    }
                                }
                                finally {
                                    if(ppidl != IntPtr.Zero) {
                                        PInvoke.CoTaskMemFree(ppidl);
                                    }
                                }
                            }
                            this.HideThumbnailTooltip();
                        }
                        else {
                            this.HideThumbnailTooltip();
                        }
                    }
                }
                if(!QTUtility.CheckConfig(Settings.NoShowSubDirTips)) {
                    if((!QTUtility.CheckConfig(Settings.SubDirTipsWithShift) ^ (modifierKeys == Keys.Shift)) && (nmlistview2.iItem > -1)) {
                        IntPtr ptr3 = IntPtr.Zero;
                        try {
                            if(((this.folderView.Item(nmlistview2.iItem, out ptr3) == 0) && (ptr3 != IntPtr.Zero)) && this.ShowSubDirTip(ptr3, nmlistview2.iItem, nmhdr.hwndFrom, false)) {
                                return false;
                            }
                        }
                        finally {
                            if(ptr3 != IntPtr.Zero) {
                                PInvoke.CoTaskMemFree(ptr3);
                            }
                        }
                    }
                    this.HideSubDirTip();
                }
            }
        Label_057E:
            return false;
        }
Пример #5
0
        private static void DrawTextOnGlass(IntPtr hDC, string text, Font font, Rectangle rct, int iGlowSize, StringAlignment horizontalAlign) {
            QTTabBarLib.Interop.RECT rect = new QTTabBarLib.Interop.RECT();
            QTTabBarLib.Interop.RECT pRect = new QTTabBarLib.Interop.RECT();
            rect.left = rct.Left;
            rect.right = rct.Right + (4 * iGlowSize);
            rect.top = rct.Top;
            rect.bottom = rct.Bottom + (2 * iGlowSize);
            pRect.left = 2 * iGlowSize;
            pRect.top = 2;
            pRect.right = rect.Width - (3 * iGlowSize);
            pRect.bottom = rect.Height - 2;
            TextFormatFlags dwFlags = TextFormatFlags.ModifyString | TextFormatFlags.NoPrefix | TextFormatFlags.SingleLine;
            switch(horizontalAlign) {
                case StringAlignment.Near:
                    dwFlags |= TextFormatFlags.EndEllipsis;
                    break;

                case StringAlignment.Center:
                    dwFlags |= TextFormatFlags.PathEllipsis | TextFormatFlags.HorizontalCenter;
                    break;

                case StringAlignment.Far:
                    dwFlags |= TextFormatFlags.Right;
                    break;
            }
            IntPtr ptr = PInvoke.CreateCompatibleDC(hDC);
            if(ptr != IntPtr.Zero) {
                IntPtr ptr5;
                QTTabBarLib.Interop.BITMAPINFO pbmi = new QTTabBarLib.Interop.BITMAPINFO();
                pbmi.bmiHeader.biSize = Marshal.SizeOf(typeof(QTTabBarLib.Interop.BITMAPINFOHEADER));
                pbmi.bmiHeader.biWidth = rect.Width;
                pbmi.bmiHeader.biHeight = -rect.Height;
                pbmi.bmiHeader.biPlanes = 1;
                pbmi.bmiHeader.biBitCount = 0x20;
                pbmi.bmiHeader.biCompression = 0;
                IntPtr hgdiobj = PInvoke.CreateDIBSection(ptr, ref pbmi, 0, out ptr5, IntPtr.Zero, 0);
                if(hgdiobj != IntPtr.Zero) {
                    IntPtr ptr3 = PInvoke.SelectObject(ptr, hgdiobj);
                    IntPtr ptr6 = font.ToHfont();
                    IntPtr ptr4 = PInvoke.SelectObject(ptr, ptr6);
                    VisualStyleRenderer renderer = new VisualStyleRenderer(VisualStyleElement.Window.Caption.Active);
                    DTTOPTS pOptions = new DTTOPTS();
                    pOptions.dwSize = Marshal.SizeOf(typeof(DTTOPTS));
                    pOptions.dwFlags = 0x2800;
                    pOptions.iGlowSize = iGlowSize;
                    PInvoke.DrawThemeTextEx(renderer.Handle, ptr, 0, 0, text, -1, dwFlags, ref pRect, ref pOptions);
                    PInvoke.BitBlt(hDC, rect.left, rect.top, rect.Width, rect.Height, ptr, 0, 0, 0xcc0020);
                    PInvoke.SelectObject(ptr, ptr3);
                    PInvoke.SelectObject(ptr, ptr4);
                    PInvoke.DeleteObject(hgdiobj);
                    PInvoke.DeleteObject(ptr6);
                }
                PInvoke.DeleteDC(ptr);
            }
        }