public void Uninstall() { try { foreach (Type type in assembly.GetTypes()) { try { if (ValidateType(type)) { MethodInfo method = type.GetMethod("Uninstall", BindingFlags.Public | BindingFlags.Static); if (method != null) { method.Invoke(null, null); } } } catch { } } } catch (Exception exception) { QTUtility2.MakeErrorLog(exception, "failed uninstall type"); } }
public void UpdateToolTipByKey(ToolStripMenuItem item) { try { if (ShowItemToolTips) { ToolTip tip = typeof(ToolStrip).GetProperty("ToolTip", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this, null) as ToolTip; if (tip != null) { tip.Hide(this); tip.Active = false; if ((item != null) && !string.IsNullOrEmpty(item.ToolTipText)) { tip.Active = true; Point point = new Point(item.Bounds.Width / 2, item.Bounds.Top + 0x20); tip.Show(item.ToolTipText, this, point, tip.AutoPopDelay); } } } } catch (Exception exception) { QTUtility2.MakeErrorLog(exception); } }
// TODO: Clean public bool TrySetSelection(Address[] addresses, string pathToFocus, bool fDeselectOthers) { if (addresses != null) { IShellFolder ppshf = null; IShellView ppshv = null; try { if (shellBrowser.QueryActiveShellView(out ppshv) == 0) { IntPtr ptr3; if (PInvoke.SHGetDesktopFolder(out ppshf) != 0) { return(false); } bool flag = true; bool flag2 = false; bool flag3 = !string.IsNullOrEmpty(pathToFocus); uint pchEaten = 0; uint pdwAttributes = 0; if (fDeselectOthers) { ((IFolderView)ppshv).SelectItem(0, 4); } foreach (Address address in addresses) { IntPtr zero = IntPtr.Zero; if ((address.ITEMIDLIST != null) && (address.ITEMIDLIST.Length > 0)) { zero = ShellMethods.CreateIDL(address.ITEMIDLIST); } if ((((zero != IntPtr.Zero) || (address.Path == null)) || ((address.Path.Length <= 0) || (ppshf.ParseDisplayName(IntPtr.Zero, IntPtr.Zero, address.Path, ref pchEaten, out zero, ref pdwAttributes) == 0))) && (zero != IntPtr.Zero)) { IntPtr pidlItem = PInvoke.ILFindLastID(zero); uint uFlags = 1; if (flag) { uFlags |= 8; if (!flag3) { flag2 = true; uFlags |= 0x10; } if (fDeselectOthers) { uFlags |= 4; } flag = false; } if ((!flag2 && flag3) && (address.Path == pathToFocus)) { flag2 = true; uFlags |= 0x10; } ppshv.SelectItem(pidlItem, uFlags); PInvoke.CoTaskMemFree(zero); } } if ((!flag2 && flag3) && (ppshf.ParseDisplayName(IntPtr.Zero, IntPtr.Zero, pathToFocus, ref pchEaten, out ptr3, ref pdwAttributes) == 0)) { IntPtr ptr4 = PInvoke.ILFindLastID(ptr3); ppshv.SelectItem(ptr4, 0x18); PInvoke.CoTaskMemFree(ptr3); } return(true); } } catch (Exception exception) { QTUtility2.MakeErrorLog(exception); } finally { if (ppshv != null) { Marshal.ReleaseComObject(ppshv); } if (ppshf != null) { Marshal.ReleaseComObject(ppshf); } } } return(false); }
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; }
private static bool TryPing(string path) { if (iPingTimeOutMS < 1) { return(false); } if (path.Length > 2) { string hostNameOrAddress; if (path.StartsWith("http://") || path.StartsWith("ftp://")) { int startIndex = path.StartsWith("http://") ? 7 : 6; int index = path.IndexOf("/", startIndex); if (index != -1) { if (index <= startIndex) { return(true); } hostNameOrAddress = path.Substring(startIndex, index - startIndex); } else { hostNameOrAddress = path.Substring(startIndex); } } else { path = path.Substring(2); int length = path.IndexOf(@"\"); if (length == -1) { hostNameOrAddress = path; } else { hostNameOrAddress = path.Substring(0, length); } } if (hostNameOrAddress.Length > 0) { try { if (!lstPingSuccessedPaths.Contains(path)) { MessageForm.Show(IntPtr.Zero, path + "\r\n\r\nWait a moment...", "Accessing network...", MessageBoxIcon.None, 0); Application.DoEvents(); } using (Ping ping = new Ping()) { if (ping.Send(hostNameOrAddress, iPingTimeOutMS).Status == IPStatus.Success) { lstPingSuccessedPaths.Add(path); return(false); } } } catch (Exception exception) { QTUtility2.MakeErrorLog(exception); } } } lstPingSuccessedPaths.Remove(path); return(true); }
static IDLWrapper() { try { string str; dicCacheIDLs = new Dictionary <string, byte[]>(); dicCSIDLTable = new Dictionary <string, int>(); dicFOLDERIDTable = new Dictionary <string, Guid>(); lstPingSuccessedPaths = new List <string>(); if (ShellMethods.TryGetFolderPath(5, out str)) { dicCSIDLTable[str.ToLower()] = 5; } if (ShellMethods.TryGetFolderPath(0x27, out str)) { dicCSIDLTable[str.ToLower()] = 0x27; } if (ShellMethods.TryGetFolderPath(0, out str)) { dicCSIDLTable[str.ToLower()] = 0; } if (ShellMethods.TryGetFolderPath(13, out str)) { dicCSIDLTable[str.ToLower()] = 13; } if (ShellMethods.TryGetFolderPath(14, out str)) { dicCSIDLTable[str.ToLower()] = 14; } if (!QTUtility.IsXP) { string str2; string str3; string str4; string str5; string str6; PATH_USERSFILES = ShellMethods.GetFolderPath(40).ToLower(); Guid rfid = new Guid("{374DE290-123F-4565-9164-39C4925E467B}"); Guid guid2 = new Guid("{4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4}"); Guid guid3 = new Guid("{bfb9d5e0-c6a9-404c-b2b2-ae6db6af4968}"); Guid guid4 = new Guid("{56784854-C6CB-462b-8169-88E350ACB882}"); Guid guid5 = new Guid("{1777F761-68AD-4D8A-87BD-30B759FA33DD}"); PInvoke.SHGetKnownFolderPath(ref rfid, 0, IntPtr.Zero, out str2); PInvoke.SHGetKnownFolderPath(ref guid2, 0, IntPtr.Zero, out str3); PInvoke.SHGetKnownFolderPath(ref guid3, 0, IntPtr.Zero, out str4); PInvoke.SHGetKnownFolderPath(ref guid4, 0, IntPtr.Zero, out str5); PInvoke.SHGetKnownFolderPath(ref guid5, 0, IntPtr.Zero, out str6); if (!string.IsNullOrEmpty(PATH_USERSFILES)) { dicFOLDERIDTable[PATH_USERSFILES] = new Guid("{f3ce0f7c-4901-4acc-8648-d5d44b04ef8f}"); dicFOLDERIDTable[PATH_USERSFILES + @"\searches"] = new Guid("{7d1d3a04-debb-4115-95cf-2f29da2920da}"); } if (!string.IsNullOrEmpty(str2)) { dicFOLDERIDTable[str2.ToLower()] = rfid; } if (!string.IsNullOrEmpty(str3)) { dicFOLDERIDTable[str3.ToLower()] = guid2; } if (!string.IsNullOrEmpty(str4)) { dicFOLDERIDTable[str4.ToLower()] = guid3; } if (!string.IsNullOrEmpty(str5)) { dicFOLDERIDTable[str5.ToLower()] = guid4; } if (!string.IsNullOrEmpty(str6)) { dicFOLDERIDTable[str6.ToLower()] = guid5; } } ReadCache(); } catch (Exception exception) { QTUtility2.MakeErrorLog(exception); } }
public static void Execute(MenuItemArguments mia, IntPtr hwnd) { if (((mia == null) || (mia.Genre != MenuGenre.Application)) || string.IsNullOrEmpty(mia.Path)) { QTUtility2.MakeErrorLog(null, "Applauncher.Execute bug found"); } else { string path = mia.Path; string argument = mia.Argument; string workingDirectory = mia.WorkingDirectory; if (!string.Equals(path, "separator", StringComparison.OrdinalIgnoreCase)) { bool flag = false; if (path.StartsWith("::")) { using (IDLWrapper wrapper = new IDLWrapper(path)) { if (wrapper.Available) { SHELLEXECUTEINFO structure = new SHELLEXECUTEINFO(); structure.cbSize = Marshal.SizeOf(structure); structure.nShow = 1; structure.fMask = 4; structure.lpIDList = wrapper.PIDL; structure.hwnd = hwnd; PInvoke.ShellExecuteEx(ref structure); return; } } flag = true; } if (path.StartsWith(@"\\")) { using (IDLWrapper wrapper2 = new IDLWrapper(path)) { if (!wrapper2.Available) { flag = true; } } } if (!flag && Directory.Exists(path)) { ProcessStartInfo startInfo = new ProcessStartInfo(path); startInfo.ErrorDialog = true; try { Process.Start(startInfo); } catch { } return; //flag = true; } if (!flag) { SHELLEXECUTEINFO shellexecuteinfo2 = new SHELLEXECUTEINFO(); shellexecuteinfo2.cbSize = Marshal.SizeOf(shellexecuteinfo2); shellexecuteinfo2.nShow = 1; shellexecuteinfo2.fMask = 0x4000200; shellexecuteinfo2.hwnd = hwnd; try { shellexecuteinfo2.lpFile = Marshal.StringToHGlobalUni(path); if (!string.IsNullOrEmpty(argument)) { shellexecuteinfo2.lpParameters = Marshal.StringToHGlobalUni(argument); } if (!string.IsNullOrEmpty(workingDirectory)) { workingDirectory = workingDirectory.Trim(new char[] { '"', '\'' }); shellexecuteinfo2.lpDirectory = Marshal.StringToHGlobalUni(workingDirectory); } else { try { shellexecuteinfo2.lpDirectory = Marshal.StringToHGlobalUni(Path.GetDirectoryName(path)); } catch { } } if (PInvoke.ShellExecuteEx(ref shellexecuteinfo2)) { string extension = Path.GetExtension(path); if (!string.Equals(".exe", extension, StringComparison.OrdinalIgnoreCase) && !string.Equals(".com", extension, StringComparison.OrdinalIgnoreCase)) { QTUtility.ExecutedPathsList.Add(path); } } } finally { if (shellexecuteinfo2.lpFile != IntPtr.Zero) { Marshal.FreeHGlobal(shellexecuteinfo2.lpFile); } if (shellexecuteinfo2.lpParameters != IntPtr.Zero) { Marshal.FreeHGlobal(shellexecuteinfo2.lpParameters); } if (shellexecuteinfo2.lpDirectory != IntPtr.Zero) { Marshal.FreeHGlobal(shellexecuteinfo2.lpDirectory); } } } else { if (!string.IsNullOrEmpty(argument)) { path = path + ", " + argument; } if (!string.IsNullOrEmpty(workingDirectory)) { path = path + ", " + workingDirectory; } MessageBox.Show("Operation failed.\r\nPlease make sure the file or the target of link exists:\r\n\r\n" + path, "Error - QTTabBar", MessageBoxButtons.OK, MessageBoxIcon.Hand); } } } }
public bool TrySetSelection(Address[] addresses, string pathToFocus, bool fDeselectOthers) { IShellView shellView = folderView as IShellView; if (addresses == null || folderView == null || shellView == null) { return(false); } try { bool fFirst = true; bool fFocused = false; bool fFocusingNeeded = !string.IsNullOrEmpty(pathToFocus); if (fDeselectOthers) { folderView.SelectItem(0, SVSIF.DESELECTOTHERS); } foreach (Address ad in addresses) { using (IDLWrapper wrapper = new IDLWrapper(ad)) { if (!wrapper.Available) { continue; } IntPtr pIDLCHILD = PInvoke.ILFindLastID(wrapper.PIDL); SVSIF svsi = SVSIF.SELECT; if (fFirst) { svsi |= SVSIF.ENSUREVISIBLE; if (!fFocusingNeeded) { fFocused = true; svsi |= SVSIF.FOCUSED; } if (fDeselectOthers) { svsi |= SVSIF.DESELECTOTHERS; } fFirst = false; } if (!fFocused && ad.Path == pathToFocus) { fFocused = true; svsi |= SVSIF.FOCUSED; } shellView.SelectItem(pIDLCHILD, svsi); } } if (!fFocused && fFocusingNeeded) { using (IDLWrapper wrapper = new IDLWrapper(pathToFocus)) { IntPtr pIDLFOCUSCHILD = PInvoke.ILFindLastID(wrapper.PIDL); shellView.SelectItem(pIDLFOCUSCHILD, SVSIF.FOCUSED | SVSIF.ENSUREVISIBLE); } } return(true); } catch (Exception ex) { QTUtility2.MakeErrorLog(ex); } return(false); }
private void btnSave_Click(object sender, RoutedEventArgs e) { string path; using (SaveFileDialog sfd = new SaveFileDialog()) { sfd.Filter = QTUtility.TextResourcesDic["FileFilters"][1] + "|*.xml"; sfd.RestoreDirectory = true; sfd.FileName = "Lng_QTTabBar_" + LangItems[1].Translated + ".xml"; if (DialogResult.OK != sfd.ShowDialog()) { return; } path = sfd.FileName; } try { using (XmlTextWriter writer = new XmlTextWriter(path, Encoding.UTF8)) { writer.WriteStartDocument(); writer.WriteWhitespace(Environment.NewLine); writer.WriteStartElement("root"); writer.WriteWhitespace(Environment.NewLine); for (int i = 0; i < 3; i++) { LangEntry entry = LangItems[i]; if (entry.Translated == "") { continue; } writer.WriteWhitespace(Environment.NewLine); writer.WriteStartElement(entry.Key); writer.WriteWhitespace(Environment.NewLine); writer.WriteValue(entry.Translated); writer.WriteWhitespace(Environment.NewLine); writer.WriteEndElement(); writer.WriteWhitespace(Environment.NewLine); } writer.WriteWhitespace(Environment.NewLine); writer.WriteStartElement("Version_QTTabBar"); writer.WriteWhitespace(Environment.NewLine); writer.WriteValue(QTUtility2.MakeVersionString()); writer.WriteWhitespace(Environment.NewLine); writer.WriteEndElement(); writer.WriteWhitespace(Environment.NewLine); writer.WriteWhitespace(Environment.NewLine); writer.WriteStartElement("DateModified"); writer.WriteWhitespace(Environment.NewLine); writer.WriteValue(DateTime.Now.ToString("MM/dd/yyyy")); writer.WriteWhitespace(Environment.NewLine); writer.WriteEndElement(); writer.WriteWhitespace(Environment.NewLine); writer.WriteWhitespace(Environment.NewLine); writer.WriteComment(" data start "); writer.WriteWhitespace(Environment.NewLine); RefInt r = new RefInt { i = 3 }; while (r.i < LangItems.Count) { string key = LangItems[r.i].Key; string line = GetStrings(key, r).StringJoin(Environment.NewLine); writer.WriteWhitespace(Environment.NewLine); writer.WriteStartElement(key); writer.WriteWhitespace(Environment.NewLine); writer.WriteValue(line); writer.WriteWhitespace(Environment.NewLine); writer.WriteEndElement(); writer.WriteWhitespace(Environment.NewLine); } writer.WriteWhitespace(Environment.NewLine); writer.WriteComment(" data end "); writer.WriteWhitespace(Environment.NewLine); writer.WriteWhitespace(Environment.NewLine); writer.WriteEndElement(); writer.WriteWhitespace(Environment.NewLine); } } catch (XmlException) { MessageBox.Show(QTUtility.TextResourcesDic["Options_Page13_Language"][10]); } catch (Exception exception2) { QTUtility2.MakeErrorLog(exception2); } }
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); }
private static ImageData LoadThumbnail2(string path, DateTime dtLastWriteTime, out Size sizeRaw, out Size sizeActual, out string toolTipText, out bool fCached) { sizeRaw = sizeActual = Size.Empty; toolTipText = null; fCached = false; IntPtr zero = IntPtr.Zero; IShellFolder ppv = null; object obj2 = null; try { IntPtr ptr3; zero = PInvoke.ILCreateFromPath(path); if ((zero != IntPtr.Zero) && (PInvoke.SHBindToParent(zero, ExplorerGUIDs.IID_IShellFolder, out ppv, out ptr3) == 0)) { uint rgfReserved = 0; Guid riid = ExplorerGUIDs.IID_IExtractImage; IntPtr[] apidl = new IntPtr[] { ptr3 }; if (ppv.GetUIObjectOf(IntPtr.Zero, 1, apidl, ref riid, ref rgfReserved, out obj2) == 0) { IntPtr ptr2; IExtractImage image = (IExtractImage)obj2; StringBuilder pszPathBuffer = new StringBuilder(260); int pdwPriority = 0; Size prgSize = new Size(QTUtility.PreviewMaxWidth, QTUtility.PreviewMaxHeight); int pdwFlags = 0x60; if (((image.GetLocation(pszPathBuffer, pszPathBuffer.Capacity, ref pdwPriority, ref prgSize, 0x18, ref pdwFlags) == 0) && (image.Extract(out ptr2) == 0)) && (ptr2 != IntPtr.Zero)) { Bitmap bmp = Image.FromHbitmap(ptr2); Size size = bmp.Size; sizeRaw = sizeActual = size; ImageData data = new ImageData(bmp, null, path, dtLastWriteTime, size, size); data.Thumbnail = true; try { toolTipText = data.TooltipText = ShellMethods.GetShellInfoTipText(zero, false); } catch { } return(data); } } } } catch (Exception exception) { QTUtility2.MakeErrorLog(exception, null); } finally { if (zero != IntPtr.Zero) { PInvoke.CoTaskMemFree(zero); } if (ppv != null) { Marshal.ReleaseComObject(ppv); } if (obj2 != null) { Marshal.ReleaseComObject(obj2); } } return(null); }
private static ImageData LoadThumbnail(string path, DateTime dtLastWriteTime, out Size sizeRaw, out Size sizeActual, out string toolTipText, out bool fCached) { sizeRaw = sizeActual = Size.Empty; toolTipText = null; fCached = false; IntPtr zero = IntPtr.Zero; IShellItem ppsi = null; ISharedBitmap ppvThumb = null; LocalThumbnailCache o = null; try { zero = PInvoke.ILCreateFromPath(path); if ((zero != IntPtr.Zero) && (PInvoke.SHCreateShellItem(IntPtr.Zero, null, zero, out ppsi) == 0)) { o = new LocalThumbnailCache(); IThumbnailCache cache2 = (IThumbnailCache)o; uint flags = 0; uint pOutFlags = 0; WTS_THUMBNAILID pThumbnailID = new WTS_THUMBNAILID(); uint cxyRequestedThumbSize = (uint)Math.Min(0x400, Math.Min(QTUtility.PreviewMaxWidth, QTUtility.PreviewMaxHeight)); if (cache2.GetThumbnail(ppsi, cxyRequestedThumbSize, flags, out ppvThumb, ref pOutFlags, ref pThumbnailID) == 0) { IntPtr ptr2; if ((pOutFlags & 2) == 2) { fCached = true; } if (ppvThumb.Detach(out ptr2) == 0) { Bitmap bmp = Image.FromHbitmap(ptr2); Size size = bmp.Size; sizeRaw = sizeActual = size; ImageData data = new ImageData(bmp, null, path, dtLastWriteTime, size, size); data.Thumbnail = true; try { toolTipText = data.TooltipText = ShellMethods.GetShellInfoTipText(zero, false); } catch { } return(data); } } } } catch (Exception exception) { QTUtility2.MakeErrorLog(exception, null); } finally { if (zero != IntPtr.Zero) { PInvoke.CoTaskMemFree(zero); } if (ppsi != null) { Marshal.ReleaseComObject(ppsi); } if (ppvThumb != null) { Marshal.ReleaseComObject(ppvThumb); } if (o != null) { Marshal.ReleaseComObject(o); } } return(null); }
public static void SaveCache(RegistryKey rkUser) { try { if (fCacheDirty && (rkUser != null)) { rkUser.DeleteSubKey("Cache", false); using (RegistryKey key = rkUser.CreateSubKey("Cache")) { if (key != null) { int num = dicCacheIDLs.Count - 0x30; List <string> list = new List <string>(); if (num > 0) { foreach (string str in dicCacheIDLs.Keys) { if (num <= 0) { break; } byte[] buffer = dicCacheIDLs[str]; if (((buffer == null) || (buffer.Length == 0)) || (buffer[0] != 20)) { list.Add(str); num--; } } foreach (string str2 in list) { dicCacheIDLs.Remove(str2); } if (num > 0) { list.Clear(); foreach (string str3 in dicCacheIDLs.Keys) { if (num <= 0) { break; } list.Add(str3); num--; } foreach (string str4 in list) { dicCacheIDLs.Remove(str4); } } } foreach (string str5 in dicCacheIDLs.Keys) { key.SetValue(str5, dicCacheIDLs[str5]); } } } } fCacheDirty = false; } catch (Exception exception) { QTUtility2.MakeErrorLog(exception, null, false); } }