protected void OnHotItemChanged(int iItem) { Keys modifierKeys = Control.ModifierKeys; if (QTUtility.CheckConfig(Settings.ShowTooltipPreviews)) { if ((thumbnailTooltip != null) && (thumbnailTooltip.IsShowing || fThumbnailPending)) { if (!QTUtility.CheckConfig(Settings.PreviewsWithShift) ^ (modifierKeys == Keys.Shift)) { if (iItem != thumbnailIndex) { if (iItem > -1 && IsTrackingItemName()) { if (ShowThumbnailTooltip(iItem, Control.MousePosition, false)) { return; } } if (thumbnailTooltip.HideToolTip()) { thumbnailIndex = -1; } } } else if (thumbnailTooltip.HideToolTip()) { thumbnailIndex = -1; } } } RefreshSubDirTip(); return; }
private void SetStyleFlags() { if (ShellBrowser.ViewMode != FVM.DETAILS) { return; } uint flags = 0; if (QTUtility.CheckConfig(Settings.DetailsGridLines)) { flags |= LVS_EX.GRIDLINES; } else { flags &= ~LVS_EX.GRIDLINES; } if (QTUtility.CheckConfig(Settings.ToggleFullRowSelect) ^ !QTUtility.IsXP) { flags |= LVS_EX.FULLROWSELECT; } else { flags &= ~LVS_EX.FULLROWSELECT; } const uint mask = LVS_EX.GRIDLINES | LVS_EX.FULLROWSELECT; PInvoke.SendMessage(Handle, LVM.SETEXTENDEDLISTVIEWSTYLE, (IntPtr)mask, (IntPtr)flags); }
public override void RefreshSubDirTip(bool force = false) { if (!QTUtility.CheckConfig(Settings.NoShowSubDirTips) && !fDragging && Control.MouseButtons == MouseButtons.None) { if ((!QTUtility.CheckConfig(Settings.SubDirTipsWithShift) ^ (Control.ModifierKeys == Keys.Shift)) && hwndExplorer == PInvoke.GetForegroundWindow()) { int iItem = GetHotItem(); if (subDirTip != null && (subDirTip.MouseIsOnThis() || subDirTip.MenuIsShowing)) { return; } if (!force && subDirIndex == iItem && (!QTUtility.IsXP || (iItem != -1))) { return; } if (!QTUtility.IsXP) { subDirIndex = iItem; } if (iItem > -1 && ShowSubDirTip(iItem, false, false)) { if (QTUtility.IsXP) { subDirIndex = iItem; } return; } } HideSubDirTip(2); subDirIndex = -1; } }
public static void InitializeMenuRenderer() { bool flag = false; if (QTUtility.CheckConfig(Settings.NonDefaultMenu)) { if (QTUtility.CheckConfig(Settings.XPStyleMenus)) { if (nCurrentRenderer != 1) { menuRenderer = new XPMenuRenderer(false); nCurrentRenderer = 1; flag = true; } } else if (nCurrentRenderer != 2) { menuRenderer = new VistaMenuRenderer(false); nCurrentRenderer = 2; flag = true; } } else if (nCurrentRenderer != 0) { menuRenderer = null; nCurrentRenderer = 0; flag = true; } if (flag && (menuRendererChanged != null)) { menuRendererChanged(null, EventArgs.Empty); } }
public void RefreshBG(bool fRebarBGCanceled) { if (fRebarBGCanceled && QTUtility.DefaultRebarCOLORREF != -1) { // Restore the default BG color PInvoke.SendMessage(Handle, RB.SETBKCOLOR, IntPtr.Zero, (IntPtr)QTUtility.DefaultRebarCOLORREF); } else if (QTUtility.CheckConfig(Settings.ToolbarBGColor)) { // Save the default color and set the new one if (QTUtility.DefaultRebarCOLORREF == -1) { QTUtility.DefaultRebarCOLORREF = (int)PInvoke.SendMessage(Handle, RB.GETBKCOLOR, IntPtr.Zero, IntPtr.Zero); } int c = QTUtility2.MakeCOLORREF(QTUtility.RebarBGColor); PInvoke.SendMessage(Handle, RB.SETBKCOLOR, IntPtr.Zero, (IntPtr)c); } // Refresh the rebar IntPtr hWnd = PInvoke.GetWindowLongPtr(Handle, -8); if (hWnd != IntPtr.Zero) { PInvoke.RedrawWindow(hWnd, IntPtr.Zero, IntPtr.Zero, 0x289); } if (QTUtility.CheckConfig(Settings.RebarImage)) { CreateRebarImage(); } }
public override void HandleShiftKey() { if (!QTUtility.CheckConfig(Settings.PreviewsWithShift)) { HideThumbnailTooltip(5); } if (!QTUtility.CheckConfig(Settings.NoShowSubDirTips)) { if (QTUtility.CheckConfig(Settings.SubDirTipsWithShift)) { if (MouseIsOverListView()) { // HandleShiftKey is called by a Hook callback, which apparently causes // problems with automation. Use PostMessage to update the SubDirTip later. hotElement = null; PInvoke.PostMessage(Handle, (uint)WM_AFTERPAINT, IntPtr.Zero, IntPtr.Zero); } } else if (!SubDirTipMenuIsShowing()) { HideSubDirTip(6); } } }
private bool IsHotTrackingEnabled() { if (thumbnailTooltip != null && (thumbnailTooltip.IsShowing || fThumbnailPending)) { return(true); } if (!fDragging && !QTUtility.CheckConfig(Settings.NoShowSubDirTips) && (!QTUtility.CheckConfig(Settings.SubDirTipsWithShift) || (Control.ModifierKeys & Keys.Shift) != 0) && Control.MouseButtons == MouseButtons.None && hwndExplorer == PInvoke.GetForegroundWindow()) { return(true); } return(false); }
private bool BreadcrumbController_MessageCaptured(ref Message msg) { if (msg.Msg == WM.MBUTTONUP) { if (!QTUtility.CheckConfig(Settings.NoCaptureMidClick) && hdpa != IntPtr.Zero && MiddleClicked != null) { int idx = HitTest(QTUtility2.PointFromLPARAM(msg.LParam)); if (idx >= 0 && idx <= ButtonCount()) { DoItemMiddleClick(IndexToCommand(idx), Control.ModifierKeys); } } } return(false); }
protected virtual void OnDragOver(Point pt) { timer_HoverSubDirTipMenu.Enabled = false; if (!QTUtility.CheckConfig(Settings.NoShowSubDirTips)) { if (QTUtility.CheckConfig(Settings.SubDirTipsWithShift)) { if (Control.ModifierKeys == Keys.Shift) { timer_HoverSubDirTipMenu_Tick(null, null); } } else { timer_HoverSubDirTipMenu.Enabled = true; } } }
protected bool OnKeyDown(Keys key) { if (QTUtility.CheckConfig(Settings.ShowTooltipPreviews)) { if (QTUtility.CheckConfig(Settings.PreviewsWithShift)) { if (key != Keys.ShiftKey) { HideThumbnailTooltip(2); } } else { HideThumbnailTooltip(2); } } if (!QTUtility.CheckConfig(Settings.NoShowSubDirTips)) { if (QTUtility.CheckConfig(Settings.SubDirTipsWithShift)) { if (key != Keys.ShiftKey) { HideSubDirTip(3); } } else if (key != Keys.ControlKey) { HideSubDirTip(3); } } if (QTUtility.CheckConfig(Settings.CursorLoop) && Control.ModifierKeys == Keys.None) { if (key == Keys.Left || key == Keys.Right || key == Keys.Up || key == Keys.Down) { return(HandleCursorLoop(key)); } } return(false); }
public RebarController(QTTabBarClass tabbar, IntPtr hwndReBar, IOleCommandTarget bandObjectSite) { this.tabbar = tabbar; this.bandObjectSite = bandObjectSite; ExplorerHandle = PInvoke.GetAncestor(hwndReBar, 2); Handle = hwndReBar; rebarController = new NativeWindowController(hwndReBar); rebarController.MessageCaptured += MessageCaptured; if (QTUtility.CheckConfig(Settings.ToolbarBGColor)) { if (QTUtility.DefaultRebarCOLORREF == -1) { QTUtility.DefaultRebarCOLORREF = (int)PInvoke.SendMessage(Handle, RB.GETBKCOLOR, IntPtr.Zero, IntPtr.Zero); } int num2 = QTUtility2.MakeCOLORREF(QTUtility.RebarBGColor); PInvoke.SendMessage(Handle, RB.SETBKCOLOR, IntPtr.Zero, (IntPtr)num2); } EnsureMenuBarIsCorrect(); }
protected bool OnGetInfoTip(int iItem, bool byKey) { if (QTUtility.CheckConfig(Settings.ShowTooltipPreviews) && (!QTUtility.CheckConfig(Settings.PreviewsWithShift) ^ (Control.ModifierKeys == Keys.Shift))) { if (((thumbnailTooltip != null) && thumbnailTooltip.IsShowing) && (iItem == thumbnailIndex)) { return(true); } else if (byKey) { Rectangle rect = GetFocusedItemRect(); Point pt = new Point(rect.Right - 32, rect.Bottom - 16); PInvoke.ClientToScreen(Handle, ref pt); return(ShowThumbnailTooltip(iItem, pt, true)); } else { return(ShowThumbnailTooltip(iItem, Control.MousePosition, false)); } } return(false); }
public static bool InitializeMenuRenderer() { bool flag = false; bool fVista = false; if (QTUtility.CheckConfig(Settings.NonDefaultMenu)) { if (QTUtility.CheckConfig(Settings.XPStyleMenus)) { if (nCurrentRenderer != 1) { menuRenderer = new XPMenuRenderer(true); nCurrentRenderer = 1; flag = true; } } else if (nCurrentRenderer != 2) { menuRenderer = new VistaMenuRenderer(true); nCurrentRenderer = 2; flag = fVista = true; } } else if (nCurrentRenderer != 0) { menuRenderer = new DefaultMenuRenderer(); nCurrentRenderer = 0; flag = true; } if (flag) { SetImageMargin(fVista); if (menuRendererChanged != null) { menuRendererChanged(null, EventArgs.Empty); } } return(flag); }
public override void HandleShiftKey() { if (!QTUtility.CheckConfig(Settings.PreviewsWithShift)) { HideThumbnailTooltip(5); } if (!QTUtility.CheckConfig(Settings.NoShowSubDirTips)) { if (QTUtility.CheckConfig(Settings.SubDirTipsWithShift)) { if (MouseIsOverListView()) { RefreshSubDirTip(); } } else if (!SubDirTipMenuIsShowing()) { HideSubDirTip(6); } } }
private bool ParentController_MessageCaptured(ref Message msg) { if (msg.Msg == WM_BREADCRUMBDPA) { hdpa = msg.LParam; return(true); } else if (msg.Msg == WM.COMMAND) { if (!QTUtility.CheckConfig(Settings.NoCaptureMidClick) && (Control.ModifierKeys & Keys.Shift) != 0 && hdpa != IntPtr.Zero && MiddleClicked != null) { int itemId = PInvoke.LoWord(msg.WParam.ToInt32()); int idx = CommandToIndex(itemId); if (idx >= 0 && idx < ButtonCount()) { DoItemMiddleClick(itemId, Control.ModifierKeys & (~Keys.Shift)); } return(true); } } return(false); }
public RebarController(QTTabBarClass tabbar, IntPtr hwndReBar, IOleCommandTarget bandObjectSite) { this.tabbar = tabbar; this.bandObjectSite = bandObjectSite; ExplorerHandle = PInvoke.GetAncestor(hwndReBar, 2); Handle = hwndReBar; rebarController = new NativeWindowController(hwndReBar); rebarController.MessageCaptured += RebarMessageCaptured; REBARBANDINFO structure = new REBARBANDINFO(); structure.cbSize = Marshal.SizeOf(structure); structure.fMask = RBBIM.CHILD | RBBIM.ID; int num = (int)PInvoke.SendMessage(Handle, RB.GETBANDCOUNT, IntPtr.Zero, IntPtr.Zero); for (int i = 0; i < num; i++) { PInvoke.SendMessage(Handle, RB.GETBANDINFO, (IntPtr)i, ref structure); if (PInvoke.GetClassName(structure.hwndChild) == "ToolbarWindow32" && structure.wID == 1) { menuController = new NativeWindowController(structure.hwndChild); menuController.MessageCaptured += MenuMessageCaptured; break; } } if (QTUtility.CheckConfig(Settings.ToolbarBGColor)) { if (QTUtility.DefaultRebarCOLORREF == -1) { QTUtility.DefaultRebarCOLORREF = (int)PInvoke.SendMessage(Handle, RB.GETBKCOLOR, IntPtr.Zero, IntPtr.Zero); } int num2 = QTUtility2.MakeCOLORREF(QTUtility.RebarBGColor); PInvoke.SendMessage(Handle, RB.SETBKCOLOR, IntPtr.Zero, (IntPtr)num2); } EnsureMenuBarIsCorrect(); }
private static void qmi_File_MouseMove(object sender, MouseEventArgs e) { if (QTUtility.CheckConfig(Settings.ShowTooltips)) { QMenuItem item = (QMenuItem)sender; if ((item.ToolTipText == null) && !string.IsNullOrEmpty(item.Path)) { string str = item.Path.StartsWith("::") ? item.Text : Path.GetFileName(item.Path); string shellInfoTipText = ShellMethods.GetShellInfoTipText(item.Path, false); if (shellInfoTipText != null) { if (str == null) { str = shellInfoTipText; } else { str = str + "\r\n" + shellInfoTipText; } } item.ToolTipText = str; } } }
public FileHashComputerForm() { InitializeComponent(); using (RegistryKey key = Registry.CurrentUser.CreateSubKey(@"Software\Quizo\QTTabBar")) { if (key != null) { int num = (int)key.GetValue("MD5FormLocation", 0x640064); int num2 = (int)key.GetValue("MD5FormSize", 0xc801c2); int num3 = (int)key.GetValue("HashType", 0); Location = new Point((short)(num & 0xffff), (short)((num >> 0x10) & 0xffff)); Size = new Size(num2 & 0xffff, (num2 >> 0x10) & 0xffff); if ((num3 < 0) || (num3 > (cmbHashType.Items.Count - 1))) { num3 = 0; } cmbHashType.SelectedIndex = num3; } } chbFullPath.Checked = QTUtility.CheckConfig(Settings.HashFullPath); chbClearOnClose.Checked = QTUtility.CheckConfig(Settings.HashClearOnClose); chbShowResult.Checked = QTUtility.CheckConfig(Settings.ShowHashResult); chbTopMost.Checked = !QTUtility.CheckConfig(Settings.HashTopMost); PInvoke.DragAcceptFiles(Handle, true); }
private bool MessageCaptured(ref Message m) { // Make sure the menu bar obeys the Explorer setting. // Was this really so hard, Microsoft? if (m.Msg == RB.SETBANDINFO) { REBARBANDINFO pInfo = (REBARBANDINFO)Marshal.PtrToStructure(m.LParam, typeof(REBARBANDINFO)); if ((PInvoke.GetClassName(pInfo.hwndChild) == "ToolbarWindow32") && (pInfo.wID == 1)) { if (MenuBarShown) { pInfo.fStyle &= ~RBBS.HIDDEN; } else { pInfo.fStyle |= RBBS.HIDDEN; } Marshal.StructureToPtr(pInfo, m.LParam, false); } return(false); } if (m.Msg == WM.ERASEBKGND && (QTUtility.CheckConfig(Settings.ToolbarBGColor) || QTUtility.CheckConfig(Settings.RebarImage))) { bool fFilled = false; using (Graphics graphics = Graphics.FromHdc(m.WParam)) { RECT rect; PInvoke.GetWindowRect(Handle, out rect); Rectangle rectangle = new Rectangle(0, 0, rect.Width, rect.Height); // Fill the Rebar background color if (QTUtility.CheckConfig(Settings.ToolbarBGColor)) { using (SolidBrush brush = new SolidBrush(QTUtility.RebarBGColor)) { graphics.FillRectangle(brush, rectangle); fFilled = true; } } // Draw the Rebar image if (VisualStyleRenderer.IsSupported && QTUtility.CheckConfig(Settings.RebarImage) && QTUtility.Path_RebarImage.Length > 0) { if (bmpRebar == null) { CreateRebarImage(); } if (bmpRebar != null) { switch (((QTUtility.ConfigValues[11] & 0x60) | (QTUtility.ConfigValues[13] & 1))) { case 1: { // Stretch on each band if (!fFilled) { rebarController.DefWndProc(ref m); } int bandCount = (int)PInvoke.SendMessage(rebarController.Handle, RB.GETBANDCOUNT, IntPtr.Zero, IntPtr.Zero); graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; RECT rectBand = new RECT(); RECT rectMargin = new RECT(); // Draw the bitmap on each band for (int i = 0; i < bandCount; i++) { if (PInvoke.SendMessage(rebarController.Handle, RB.GETRECT, (IntPtr)i, ref rectBand) == IntPtr.Zero) { continue; } PInvoke.SendMessage(rebarController.Handle, RB.GETBANDBORDERS, (IntPtr)i, ref rectMargin); rectBand.left -= !QTUtility.IsXP ? 4 : rectMargin.left; rectBand.top -= rectMargin.top; rectBand.right += rectMargin.right; rectBand.bottom += rectMargin.bottom; graphics.DrawImage(bmpRebar, rectBand.ToRectangle()); } break; } case 0x20: { // Real size if (!fFilled) { rebarController.DefWndProc(ref m); } Rectangle destRect = new Rectangle(Point.Empty, bmpRebar.Size); graphics.DrawImage(bmpRebar, destRect, destRect, GraphicsUnit.Pixel); break; } case 0x40: // Tile textureBrushRebar = textureBrushRebar ?? new TextureBrush(bmpRebar); graphics.FillRectangle(textureBrushRebar, rectangle); break; default: // Full size graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; graphics.DrawImage(bmpRebar, rectangle); break; } fFilled = true; } } } if (fFilled) { m.Result = (IntPtr)1; return(true); } } return(false); }
protected override bool OnShellViewNotify(NMHDR nmhdr, ref Message msg) { // Process WM.NOTIFY. These are all notifications from the // SysListView32 control. We will not get ANY of these on // Windows 7, which means every single one of them has to // have an alternative somewhere for the ItemsView control, // or it's not going to happen. switch (nmhdr.code) { case -12: // NM_CUSTOMDRAW // This is for drawing alternating row colors. I doubt // very much we'll find an alternative for this... return(HandleCustomDraw(ref msg)); case LVN.ITEMCHANGED: { // There are two things happening here. // 1. Notify plugins of selection changing: Handled through // undocumented WM_USER+163 message // 2. Redraw for Full Row Select: Not happening /* * // TODO * * IntPtr ptr; * if(QTUtility.instanceManager.TryGetButtonBarHandle(this.hwndExplorer, out ptr)) { * QTUtility2.SendCOPYDATASTRUCT(ptr, (IntPtr)13, null, (IntPtr)GetItemCount()); * } */ bool flag = !QTUtility.IsXP && QTUtility.CheckConfig(Settings.ToggleFullRowSelect); NMLISTVIEW nmlistview2 = (NMLISTVIEW)Marshal.PtrToStructure(msg.LParam, typeof(NMLISTVIEW)); if (nmlistview2.uChanged == 8 /*LVIF_STATE*/) { uint num5 = nmlistview2.uNewState & LVIS.SELECTED; uint num6 = nmlistview2.uOldState & LVIS.SELECTED; uint num7 = nmlistview2.uNewState & LVIS.DROPHILITED; uint num8 = nmlistview2.uOldState & LVIS.DROPHILITED; uint num9 = nmlistview2.uNewState & LVIS.CUT; uint num10 = nmlistview2.uOldState & LVIS.CUT; if (flag) { if (nmlistview2.iItem != -1 && ((num5 != num6) || (num7 != num8) || (num9 != num10)) && ShellBrowser.ViewMode == FVM.DETAILS) { PInvoke.SendMessage(nmlistview2.hdr.hwndFrom, LVM.REDRAWITEMS, (IntPtr)nmlistview2.iItem, (IntPtr)nmlistview2.iItem); } } if (num5 != num6) { OnSelectionChanged(); } } break; } case LVN.INSERTITEM: case LVN.DELETEITEM: // Handled through undocumented WM_USER+174 message if (!QTUtility.CheckConfig(Settings.NoShowSubDirTips)) { HideSubDirTip(1); } if (QTUtility.CheckConfig(Settings.AlternateRowColors) && (ShellBrowser.ViewMode == FVM.DETAILS)) { PInvoke.InvalidateRect(nmhdr.hwndFrom, IntPtr.Zero, true); } ShellViewController.DefWndProc(ref msg); OnItemCountChanged(); return(true); case LVN.BEGINDRAG: // This won't be necessary it seems. On Windows 7, when you // start to drag, a MOUSELEAVE message is sent, which hides // the SubDirTip anyway. ShellViewController.DefWndProc(ref msg); HideSubDirTip(0xff); return(true); case LVN.ITEMACTIVATE: { // Handled by catching Double Clicks and Enter keys. Ugh... NMITEMACTIVATE nmitemactivate = (NMITEMACTIVATE)Marshal.PtrToStructure(msg.LParam, typeof(NMITEMACTIVATE)); Keys modKeys = (((nmitemactivate.uKeyFlags & 1) == 1) ? Keys.Alt : Keys.None) | (((nmitemactivate.uKeyFlags & 2) == 2) ? Keys.Control : Keys.None) | (((nmitemactivate.uKeyFlags & 4) == 4) ? Keys.Shift : Keys.None); if (OnItemActivated(modKeys)) { return(true); } break; } case LVN.ODSTATECHANGED: // FullRowSelect doesn't look possible anyway, so whatever. if (!QTUtility.IsXP && QTUtility.CheckConfig(Settings.ToggleFullRowSelect)) { NMLVODSTATECHANGE nmlvodstatechange = (NMLVODSTATECHANGE)Marshal.PtrToStructure(msg.LParam, typeof(NMLVODSTATECHANGE)); if (((nmlvodstatechange.uNewState & 2) == 2) && (ShellBrowser.ViewMode == FVM.DETAILS)) { PInvoke.SendMessage(nmlvodstatechange.hdr.hwndFrom, LVM.REDRAWITEMS, (IntPtr)nmlvodstatechange.iFrom, (IntPtr)nmlvodstatechange.iTo); } } break; case LVN.HOTTRACK: // Handled through WM_MOUSEMOVE. if (QTUtility.CheckConfig(Settings.ShowTooltipPreviews) || !QTUtility.CheckConfig(Settings.NoShowSubDirTips)) { NMLISTVIEW nmlistview = (NMLISTVIEW)Marshal.PtrToStructure(msg.LParam, typeof(NMLISTVIEW)); int iItem = CorrectHotItem(nmlistview.iItem); if (iHotItem != iItem) { OnHotItemChanged(iItem); iHotItem = iItem; } } break; case LVN.KEYDOWN: { // Handled through WM_KEYDOWN. NMLVKEYDOWN nmlvkeydown = (NMLVKEYDOWN)Marshal.PtrToStructure(msg.LParam, typeof(NMLVKEYDOWN)); if (OnKeyDown((Keys)nmlvkeydown.wVKey)) { msg.Result = (IntPtr)1; return(true); } else { return(false); } } case LVN.GETINFOTIP: { // Handled through WM_NOTIFY / TTN_NEEDTEXT NMLVGETINFOTIP nmlvgetinfotip = (NMLVGETINFOTIP)Marshal.PtrToStructure(msg.LParam, typeof(NMLVGETINFOTIP)); return(OnGetInfoTip(nmlvgetinfotip.iItem, GetHotItem() != nmlvgetinfotip.iItem)); // TODO there's got to be a better way. } case LVN.BEGINLABELEDIT: // This is just for file renaming, which there's no need to // mess with in Windows 7. ShellViewController.DefWndProc(ref msg); if (QTUtility.IsXP && !QTUtility.CheckConfig(Settings.ExtWhileRenaming)) { NMLVDISPINFO nmlvdispinfo = (NMLVDISPINFO)Marshal.PtrToStructure(msg.LParam, typeof(NMLVDISPINFO)); if (nmlvdispinfo.item.lParam != IntPtr.Zero) { using (IDLWrapper idl = ShellBrowser.ILAppend(nmlvdispinfo.item.lParam)) { OnFileRename(idl); } } } break; case LVN.ENDLABELEDIT: { // TODO NMLVDISPINFO nmlvdispinfo2 = (NMLVDISPINFO)Marshal.PtrToStructure(msg.LParam, typeof(NMLVDISPINFO)); OnEndLabelEdit(nmlvdispinfo2.item); break; } } return(false); }
private bool HandleCustomDraw(ref Message msg) { // TODO this needs to be cleaned if (QTUtility.CheckConfig(Settings.AlternateRowColors) && (ShellBrowser.ViewMode == FVM.DETAILS)) { NMLVCUSTOMDRAW structure = (NMLVCUSTOMDRAW)Marshal.PtrToStructure(msg.LParam, typeof(NMLVCUSTOMDRAW)); int dwItemSpec = 0; if ((ulong)structure.nmcd.dwItemSpec < Int32.MaxValue) { dwItemSpec = (int)structure.nmcd.dwItemSpec; } switch (structure.nmcd.dwDrawStage) { case CDDS.SUBITEM | CDDS.ITEMPREPAINT: iListViewItemState = (int)PInvoke.SendMessage( ListViewController.Handle, LVM.GETITEMSTATE, structure.nmcd.dwItemSpec, (IntPtr)(LVIS.FOCUSED | LVIS.SELECTED | LVIS.DROPHILITED)); if (!QTUtility.IsXP) { int num4 = lstColumnFMT[structure.iSubItem]; structure.clrTextBk = QTUtility.ShellViewRowCOLORREF_Background; structure.clrText = QTUtility.ShellViewRowCOLORREF_Text; Marshal.StructureToPtr(structure, msg.LParam, false); bool drawingHotItem = (dwItemSpec == GetHotItem()); bool fullRowSel = !QTUtility.CheckConfig(Settings.ToggleFullRowSelect); msg.Result = (IntPtr)(CDRF.NEWFONT); if (structure.iSubItem == 0 && !drawingHotItem) { if (iListViewItemState == 0 && (num4 & 0x600) != 0) { msg.Result = (IntPtr)(CDRF.NEWFONT | CDRF.NOTIFYPOSTPAINT); } else if (iListViewItemState == LVIS.FOCUSED && !fullRowSel) { msg.Result = (IntPtr)(CDRF.NEWFONT | CDRF.NOTIFYPOSTPAINT); } } if (structure.iSubItem > 0 && (!fullRowSel || !drawingHotItem)) { if (!fullRowSel || (iListViewItemState & (LVIS.SELECTED | LVIS.DROPHILITED)) == 0) { using (Graphics graphics = Graphics.FromHdc(structure.nmcd.hdc)) { if (QTUtility.sbAlternate == null) { QTUtility.sbAlternate = new SolidBrush(QTUtility2.MakeColor(QTUtility.ShellViewRowCOLORREF_Background)); } graphics.FillRectangle(QTUtility.sbAlternate, structure.nmcd.rc.ToRectangle()); } } } } else { msg.Result = (IntPtr)(CDRF.NOTIFYPOSTPAINT); } return(true); case CDDS.SUBITEM | CDDS.ITEMPOSTPAINT: { RECT rc = structure.nmcd.rc; if (QTUtility.IsXP) { rc = PInvoke.ListView_GetItemRect(ListViewController.Handle, dwItemSpec, structure.iSubItem, 2); } else { rc.left += 0x10; } bool flag3 = false; bool flag4 = false; bool flag5 = QTUtility.CheckConfig(Settings.DetailsGridLines); bool flag6 = QTUtility.CheckConfig(Settings.ToggleFullRowSelect) ^ !QTUtility.IsXP; bool flag7 = false; if (QTUtility.IsXP && QTUtility.fSingleClick) { flag7 = (dwItemSpec == GetHotItem()); } LVITEM lvitem = new LVITEM(); lvitem.pszText = Marshal.AllocHGlobal(520); lvitem.cchTextMax = 260; lvitem.iSubItem = structure.iSubItem; lvitem.iItem = dwItemSpec; lvitem.mask = 1; IntPtr ptr3 = Marshal.AllocHGlobal(Marshal.SizeOf(lvitem)); Marshal.StructureToPtr(lvitem, ptr3, false); PInvoke.SendMessage(ListViewController.Handle, LVM.GETITEM, IntPtr.Zero, ptr3); if (QTUtility.sbAlternate == null) { QTUtility.sbAlternate = new SolidBrush(QTUtility2.MakeColor(QTUtility.ShellViewRowCOLORREF_Background)); } using (Graphics graphics2 = Graphics.FromHdc(structure.nmcd.hdc)) { Rectangle rect = rc.ToRectangle(); if (flag5) { rect = new Rectangle(rc.left + 1, rc.top, rc.Width - 1, rc.Height - 1); } graphics2.FillRectangle(QTUtility.sbAlternate, rect); if (QTUtility.IsXP && ((structure.iSubItem == 0) || flag6)) { flag4 = (iListViewItemState & 8) == 8; if ((iListViewItemState != 0) && (((iListViewItemState == 1) && fListViewHasFocus) || (iListViewItemState != 1))) { int width; if (flag6) { width = rc.Width; } else { width = 8 + ((int)PInvoke.SendMessage(ListViewController.Handle, LVM.GETSTRINGWIDTH, IntPtr.Zero, lvitem.pszText)); if (width > rc.Width) { width = rc.Width; } } Rectangle rectangle2 = new Rectangle(rc.left, rc.top, width, flag5 ? (rc.Height - 1) : rc.Height); if (((iListViewItemState & 2) == 2) || flag4) { if (flag4) { graphics2.FillRectangle(SystemBrushes.Highlight, rectangle2); } else if (QTUtility.fSingleClick && flag7) { graphics2.FillRectangle(fListViewHasFocus ? SystemBrushes.HotTrack : SystemBrushes.Control, rectangle2); } else { graphics2.FillRectangle(fListViewHasFocus ? SystemBrushes.Highlight : SystemBrushes.Control, rectangle2); } flag3 = true; } if ((fListViewHasFocus && ((iListViewItemState & 1) == 1)) && !flag6) { ControlPaint.DrawFocusRectangle(graphics2, rectangle2); } } } if (!QTUtility.IsXP && ((iListViewItemState & 1) == 1)) { int num6 = rc.Width; if (!flag6) { num6 = 4 + ((int)PInvoke.SendMessage(ListViewController.Handle, LVM.GETSTRINGWIDTH, IntPtr.Zero, lvitem.pszText)); if (num6 > rc.Width) { num6 = rc.Width; } } Rectangle rectangle = new Rectangle(rc.left + 1, rc.top + 1, num6, flag5 ? (rc.Height - 2) : (rc.Height - 1)); ControlPaint.DrawFocusRectangle(graphics2, rectangle); } } IntPtr zero = IntPtr.Zero; IntPtr hgdiobj = IntPtr.Zero; if (QTUtility.IsXP && QTUtility.fSingleClick) { LOGFONT logfont; zero = PInvoke.GetCurrentObject(structure.nmcd.hdc, 6); PInvoke.GetObject(zero, Marshal.SizeOf(typeof(LOGFONT)), out logfont); if ((structure.iSubItem == 0) || flag6) { logfont.lfUnderline = ((QTUtility.iIconUnderLineVal == 3) || flag7) ? ((byte)1) : ((byte)0); } else { logfont.lfUnderline = 0; } hgdiobj = PInvoke.CreateFontIndirect(ref logfont); PInvoke.SelectObject(structure.nmcd.hdc, hgdiobj); } PInvoke.SetBkMode(structure.nmcd.hdc, 1); int dwDTFormat = 0x8824; if (QTUtility.IsRTL ? ((lstColumnFMT[structure.iSubItem] & 1) == 0) : ((lstColumnFMT[structure.iSubItem] & 1) == 1)) { if (QTUtility.IsRTL) { dwDTFormat &= -3; } else { dwDTFormat |= 2; } rc.right -= 6; } else if (structure.iSubItem == 0) { rc.left += 2; rc.right -= 2; } else { rc.left += 6; } if (flag3) { PInvoke.SetTextColor(structure.nmcd.hdc, QTUtility2.MakeCOLORREF((fListViewHasFocus || flag4) ? SystemColors.HighlightText : SystemColors.WindowText)); } else { PInvoke.SetTextColor(structure.nmcd.hdc, QTUtility.ShellViewRowCOLORREF_Text); } PInvoke.DrawTextExW(structure.nmcd.hdc, lvitem.pszText, -1, ref rc, dwDTFormat, IntPtr.Zero); Marshal.FreeHGlobal(lvitem.pszText); Marshal.FreeHGlobal(ptr3); msg.Result = IntPtr.Zero; if (zero != IntPtr.Zero) { PInvoke.SelectObject(structure.nmcd.hdc, zero); } if (hgdiobj != IntPtr.Zero) { PInvoke.DeleteObject(hgdiobj); } return(true); } case CDDS.ITEMPREPAINT: if ((dwItemSpec % 2) == 0) { msg.Result = (IntPtr)0x20; return(true); } msg.Result = IntPtr.Zero; return(false); case CDDS.PREPAINT: { HDITEM hditem = new HDITEM(); hditem.mask = 4; IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(hditem)); Marshal.StructureToPtr(hditem, ptr, false); IntPtr hWnd = PInvoke.SendMessage(ListViewController.Handle, LVM.GETHEADER, IntPtr.Zero, IntPtr.Zero); int num2 = (int)PInvoke.SendMessage(hWnd, 0x1200, IntPtr.Zero, IntPtr.Zero); if (lstColumnFMT == null) { lstColumnFMT = new List <int>(); } else { lstColumnFMT.Clear(); } for (int i = 0; i < num2; i++) { PInvoke.SendMessage(hWnd, 0x120b, (IntPtr)i, ptr); hditem = (HDITEM)Marshal.PtrToStructure(ptr, typeof(HDITEM)); lstColumnFMT.Add(hditem.fmt); } Marshal.FreeHGlobal(ptr); fListViewHasFocus = ListViewController.Handle == PInvoke.GetFocus(); msg.Result = (IntPtr)0x20; return(true); } } } return(false); }
private bool CreateThumbnail(string path, ref Size formSize) { string ext = Path.GetExtension(path).ToLower(); if (ExtIsImage(ext)) { FileInfo info = new FileInfo(path); if (!info.Exists || (info.Length <= 0L)) { goto Label_0635; } bool flag = false; bool thumbnail = false; bool fCached = false; Bitmap bitmap = null; ImageData item = null; Size empty = Size.Empty; Size sizeActual = Size.Empty; lblInfo.Text = string.Empty; string toolTipText = null; if ((maxWidth != QTUtility.PreviewMaxWidth) || (maxHeight != QTUtility.PreviewMaxHeight)) { maxWidth = QTUtility.PreviewMaxWidth; maxHeight = QTUtility.PreviewMaxHeight; pictureBox1.Image = null; imageCacheStore.Clear(); lstPathFailedThumbnail.Clear(); } foreach (ImageData data2 in imageCacheStore) { if (string.Equals(data2.Path, path, StringComparison.OrdinalIgnoreCase)) { if (data2.ModifiedDate == info.LastWriteTime) { bitmap = data2.Bitmap; thumbnail = data2.Thumbnail; empty = data2.RawSize; sizeActual = data2.ZoomedSize; toolTipText = data2.TooltipText; flag = true; } else { item = data2; } break; } } if (item != null) { imageCacheStore.Remove(item); } if (!flag) { try { ImageData data3; if (!ExtIsDefaultImage(ext)) { if (lstPathFailedThumbnail.Contains(path)) { return(false); } thumbnail = true; if (!QTUtility.IsXP) { data3 = LoadThumbnail(path, info.LastWriteTime, out empty, out sizeActual, out toolTipText, out fCached); } else { data3 = LoadThumbnail2(path, info.LastWriteTime, out empty, out sizeActual, out toolTipText, out fCached); } } else { data3 = LoadImageFile(path, info.LastWriteTime, out empty, out sizeActual); } if (data3 == null) { lstPathFailedThumbnail.Add(path); return(false); } bitmap = data3.Bitmap; imageCacheStore.Add(data3); } catch { return(false); } } int width = 0x9e; if (width < sizeActual.Width) { width = sizeActual.Width; } bool flag4 = false; if (!QTUtility.CheckConfig(Settings.PreviewInfo)) { SizeF ef; string text = Path.GetFileName(path) + "\r\n"; if (thumbnail && (toolTipText != null)) { text = text + toolTipText; } else { bool flag5 = sizeActual == empty; text = text + FormatSize(info.Length); if (!thumbnail) { object obj2 = text; text = string.Concat(new object[] { obj2, " ( ", empty.Width, " x ", empty.Height, " )", flag5 ? string.Empty : "*" }); } text = text + "\r\n" + info.LastWriteTime; } using (Graphics graphics = lblInfo.CreateGraphics()) { ef = graphics.MeasureString(text, lblInfo.Font, (width - 8)); } lblInfo.SuspendLayout(); lblInfo.Text = text; lblInfo.Width = width; lblInfo.Height = (int)(ef.Height + 8f); lblInfo.ResumeLayout(); formSize = new Size(width + 8, (sizeActual.Height + lblInfo.Height) + 8); } else { flag4 = true; formSize = new Size(width + 8, sizeActual.Height + 8); } try { SuspendLayout(); if (flag4) { lblInfo.Dock = DockStyle.None; } else { lblInfo.Dock = DockStyle.Bottom; lblInfo.BringToFront(); } pictureBox1.SuspendLayout(); pictureBox1.SizeMode = (sizeActual != bitmap.Size) ? PictureBoxSizeMode.Zoom : PictureBoxSizeMode.CenterImage; pictureBox1.Image = bitmap; pictureBox1.ResumeLayout(); pictureBox1.BringToFront(); ResumeLayout(); return(true); } catch (Exception exception) { QTUtility2.MakeErrorLog(exception, null); goto Label_0635; } } if (ExtIsText(ext)) { FileInfo info2 = new FileInfo(path); if (info2.Exists) { try { SizeF ef2; bool fLoadedAll = false; bool flag7 = false; string str4; ioException = null; if (info2.Length > 0L) { str4 = LoadTextFile(path, out fLoadedAll); } else { flag7 = true; str4 = " *empty file"; } lblText.ForeColor = (ioException != null) ? Color.Red : (flag7 ? SystemColors.GrayText : SystemColors.InfoText); if (!string.IsNullOrEmpty(QTUtility.PreviewFontName)) { if ((lblText.Font.Name != QTUtility.PreviewFontName) || (lblText.Font.Size != QTUtility.PreviewFontSize)) { fFontAsigned = true; try { lblText.Font = new Font(QTUtility.PreviewFontName, QTUtility.PreviewFontSize); } catch { } } } else if (fFontAsigned) { fFontAsigned = false; lblText.Font = null; } int num2 = 0x100; if (fFontAsigned) { num2 = Math.Max((int)(num2 * (QTUtility.PreviewFontSize / DefaultFont.Size)), 0x80); formSize.Width = num2; } using (Graphics graphics2 = lblText.CreateGraphics()) { ef2 = graphics2.MeasureString(str4, lblText.Font, num2); } if ((ef2.Height < 512f) || fLoadedAll) { formSize.Height = (int)(ef2.Height + 8f); } else { formSize.Height = 0x200; } SuspendLayout(); lblInfo.Dock = DockStyle.None; lblText.Text = str4; lblText.BringToFront(); ResumeLayout(); return(true); } catch (Exception exception2) { QTUtility2.MakeErrorLog(exception2, null); return(false); } } } Label_0635: return(false); }