示例#1
0
        private static Image GetImage(PathData pathData)
        {
            string strImageKey = pathData.strImageKey;

            if (!QTUtility.ImageListGlobal.Images.ContainsKey(strImageKey))
            {
                strImageKey = QTUtility.GetImageKey(pathData.strPath, null);
            }
            return(QTUtility.ImageListGlobal.Images[strImageKey]);
        }
示例#2
0
 private void UpdateContextMenu()
 {
     contextMenuNotifyIcon.Hide();
     contextMenuNotifyIcon.SuspendLayout();
     contextMenuNotifyIcon.Items.Clear();
     foreach (var inst in dicNotifyIcon.Values)
     {
         StringBuilder lpString = new StringBuilder(260);
         PInvoke.GetWindowText(inst.ExplorerHandle, lpString, lpString.Capacity);
         ToolStripMenuItem item = new ToolStripMenuItem(lpString.ToString());
         item.Tag = inst.TabBarHandle;
         if (inst.CurrentPath.Length > 0)
         {
             item.ToolTipText = QTUtility2.MakePathDisplayText(inst.CurrentPath, true);
             item.ImageKey    = QTUtility.GetImageKey(inst.CurrentPath, null);
         }
         int j = Math.Min(inst.TabNames.Length, inst.TabPaths.Length);
         if (j > 1)
         {
             for (int i = 0; i < j; i++)
             {
                 item.DropDownItems.Add(new ToolStripMenuItem(inst.TabNames[i])
                 {
                     Tag         = inst.TabBarHandle,
                     ToolTipText = QTUtility2.MakePathDisplayText(inst.TabPaths[i], true),
                     ImageKey    = QTUtility.GetImageKey(inst.TabPaths[i], null)
                 });
             }
             if (item.DropDownItems.Count > 0)
             {
                 item.DropDownItemClicked += contextMenuNotifyIcon_SubItems_DropDownItemClicked;
                 item.DropDown.ImageList   = QTUtility.ImageListGlobal;
             }
         }
         contextMenuNotifyIcon.Items.Add(item);
     }
     contextMenuNotifyIcon.Items.Add(new ToolStripSeparator());
     contextMenuNotifyIcon.Items.Add(new ToolStripMenuItem("Restore all")
     {
         Tag = 0
     });
     contextMenuNotifyIcon.Items.Add(new ToolStripMenuItem("Close all")
     {
         Tag = 1
     });
     contextMenuNotifyIcon.ResumeLayout();
 }
示例#3
0
 public void ShowFileHashForm(string[] paths)
 {
     if (!fCancellationPending)
     {
         ClearNewColor();
         Text = MakeHashTypeText() + QTUtility.TextResourcesDic["FileHashComputer"][9];
         SetButtonsEnabled(false);
         List <string>          list = new List <string>();
         List <DataGridViewRow> rows = new List <DataGridViewRow>();
         bool flag = chbFullPath.Checked;
         if (paths != null)
         {
             dgvHash.SuspendLayout();
             foreach (string str in paths)
             {
                 FileInfo info = new FileInfo(str);
                 if (info.Exists)
                 {
                     DateTime lastWriteTime       = info.LastWriteTime;
                     List <DataGridViewRow> list3 = new List <DataGridViewRow>();
                     List <DataGridViewRow> list4 = new List <DataGridViewRow>();
                     int  rowIndex = -1;
                     bool flag2    = false;
                     foreach (DataGridViewRow row in dgvHash.Rows)
                     {
                         if (!flag2 && row.Cells[1].ToolTipText.PathEquals(str))
                         {
                             if ((row.Tag != null) && (lastWriteTime != ((RowProperties)row.Tag).modTime))
                             {
                                 list3.Add(row);
                                 row.Selected = false;
                             }
                             else if (((DataGridViewProgressBarCell)row.Cells[2]).CalculatingStatus == HashCalcStatus.Aborted)
                             {
                                 list4.Add(row);
                             }
                             else
                             {
                                 row.Selected = true;
                                 flag2        = true;
                             }
                         }
                         else
                         {
                             row.Selected = false;
                         }
                     }
                     foreach (DataGridViewRow row2 in list4)
                     {
                         rowIndex = row2.Index;
                         dgvHash.Rows.Remove(row2);
                     }
                     if (!flag2)
                     {
                         DataGridViewRow item = new DataGridViewRow();
                         item.CreateCells(dgvHash, new object[] { QTUtility.ImageListGlobal.Images[QTUtility.GetImageKey(str, Path.GetExtension(str))], flag ? str : Path.GetFileName(str), VALUE_EMPTY });
                         item.Cells[0].Style.BackColor = clrNew;
                         item.Cells[1].ToolTipText     = str;
                         item.Tag = new RowProperties(lastWriteTime);
                         if (list3.Count > 0)
                         {
                             RowProperties tag = (RowProperties)list3[0].Tag;
                             if (tag.colorIndexModTimeDiffers < 0)
                             {
                                 list3.Add(item);
                                 foreach (DataGridViewRow row4 in list3)
                                 {
                                     ((RowProperties)row4.Tag).colorIndexModTimeDiffers = colorIndexModTimeDiffers;
                                     row4.Cells[1].Style.BackColor = colors[colorIndexModTimeDiffers];
                                 }
                                 colorIndexModTimeDiffers++;
                                 if (colorIndexModTimeDiffers > (colors.Length - 1))
                                 {
                                     colorIndexModTimeDiffers = 0;
                                 }
                             }
                             else
                             {
                                 ((RowProperties)item.Tag).colorIndexModTimeDiffers = tag.colorIndexModTimeDiffers;
                                 item.Cells[1].Style.BackColor = colors[tag.colorIndexModTimeDiffers];
                             }
                         }
                         if (rowIndex != -1)
                         {
                             dgvHash.Rows.Insert(rowIndex, item);
                         }
                         else
                         {
                             dgvHash.Rows.Add(item);
                         }
                         dgvHash.FirstDisplayedScrollingRowIndex = dgvHash.Rows.IndexOf(item);
                         list.Add(str);
                         rows.Add(item);
                         clmn3_Hash.InitializeProgress((DataGridViewProgressBarCell)item.Cells[2]);
                     }
                 }
             }
             if (list.Count > 0)
             {
                 if (iThreadsCounter > 0)
                 {
                     qPendings.Enqueue(new PathRowPairs(list, rows));
                 }
                 else
                 {
                     iThreadsCounter++;
                     new HashInvoker(ComputeHashCore).BeginInvoke(list.ToArray(), rows.ToArray(), cmbHashType.SelectedIndex, AsyncComplete, null);
                 }
             }
             dgvHash.ResumeLayout();
         }
         Show();
         PInvoke.SetWindowPos(Handle, chbTopMost.Checked ? ((IntPtr)(-1)) : IntPtr.Zero, 0, 0, 0, 0, 0x53);
         if (list.Count == 0)
         {
             ComputeFinished();
         }
     }
 }
示例#4
0
        public static string TrackGroupContextMenu(string groupName, Point pnt, IntPtr pDropDownHandle)
        {
            string str;
            string name = string.Empty;

            if (!QTUtility.GroupPathsDic.TryGetValue(groupName, out str))
            {
                return(name);
            }
            string[]    strArray = str.Split(QTUtility.SEPARATOR_CHAR);
            ContextMenu menu     = new ContextMenu();

            if (QTUtility.IsVista)
            {
                for (int i = 0; i < strArray.Length; i++)
                {
                    string text = string.Empty;
                    if (strArray[i].StartsWith(@"\\"))
                    {
                        text = strArray[i];
                    }
                    else
                    {
                        text = ShellMethods.GetDisplayName(strArray[i]);
                    }
                    MenuItem item = new MenuItem(text);
                    item.Name = strArray[i];
                    menu.MenuItems.Add(item);
                }
            }
            else
            {
                for (int j = 0; j < strArray.Length; j++)
                {
                    string displayName = string.Empty;
                    if (strArray[j].StartsWith(@"\\"))
                    {
                        displayName = strArray[j];
                    }
                    else
                    {
                        displayName = ShellMethods.GetDisplayName(strArray[j]);
                    }
                    MenuItemEx ex = new MenuItemEx(displayName);
                    ex.Name  = strArray[j];
                    ex.Image = QTUtility.ImageListGlobal.Images[QTUtility.GetImageKey(strArray[j], null)];
                    menu.MenuItems.Add(ex);
                }
            }
            List <IntPtr> list = new List <IntPtr>();

            if (QTUtility.IsVista)
            {
                for (int k = 0; k < strArray.Length; k++)
                {
                    string imageKey = QTUtility.GetImageKey(strArray[k], null);
                    IntPtr hbitmap  = ((Bitmap)QTUtility.ImageListGlobal.Images[imageKey]).GetHbitmap(System.Drawing.Color.Black);
                    if (hbitmap != IntPtr.Zero)
                    {
                        list.Add(hbitmap);
                        PInvoke.SetMenuItemBitmaps(menu.Handle, k, 0x400, hbitmap, IntPtr.Zero);
                    }
                }
            }
            uint maxValue = uint.MaxValue;

            if (menu.MenuItems.Count > 0)
            {
                maxValue = PInvoke.TrackPopupMenu(menu.Handle, 0x180, pnt.X, pnt.Y, 0, pDropDownHandle, IntPtr.Zero);
                if (maxValue != 0)
                {
                    for (int m = 0; m < menu.MenuItems.Count; m++)
                    {
                        if (maxValue == PInvoke.GetMenuItemID(menu.Handle, m))
                        {
                            name = menu.MenuItems[m].Name;
                            break;
                        }
                    }
                }
            }
            menu.Dispose();
            if (QTUtility.IsVista)
            {
                foreach (IntPtr ptr2 in list)
                {
                    PInvoke.DeleteObject(ptr2);
                }
            }
            if (maxValue != 0)
            {
                return(name);
            }
            return(null);
        }
示例#5
0
        // TODO: what does this do?!
        // TODO: whatever it does, it should be returning an idl, not a path.
        public static string TrackGroupContextMenu(string groupName, Point pnt, IntPtr pDropDownHandle)
        {
            string name = string.Empty;
            Group  g    = GroupsManager.GetGroup(groupName);

            if (g == null)
            {
                return(name);
            }
            ContextMenu menu = new ContextMenu();

            if (!QTUtility.IsXP)
            {
                foreach (string str2 in g.Paths)
                {
                    string text;
                    if (str2.StartsWith(@"\\"))
                    {
                        text = str2;
                    }
                    else
                    {
                        text = ShellMethods.GetDisplayName(str2);
                    }
                    MenuItem item = new MenuItem(text);
                    item.Name = str2;
                    menu.MenuItems.Add(item);
                }
            }
            else
            {
                foreach (string path in g.Paths)
                {
                    string displayName;
                    if (path.StartsWith(@"\\"))
                    {
                        displayName = path;
                    }
                    else
                    {
                        displayName = ShellMethods.GetDisplayName(path);
                    }
                    MenuItemEx ex = new MenuItemEx(displayName);
                    ex.Name  = path;
                    ex.Image = QTUtility.ImageListGlobal.Images[QTUtility.GetImageKey(path, null)];
                    menu.MenuItems.Add(ex);
                }
            }
            List <IntPtr> list = new List <IntPtr>();

            if (!QTUtility.IsXP)
            {
                for (int k = 0; k < g.Paths.Count; k++)
                {
                    string imageKey = QTUtility.GetImageKey(g.Paths[k], null);
                    IntPtr hbitmap  = ((Bitmap)QTUtility.ImageListGlobal.Images[imageKey]).GetHbitmap(Color.Black);
                    if (hbitmap != IntPtr.Zero)
                    {
                        list.Add(hbitmap);
                        PInvoke.SetMenuItemBitmaps(menu.Handle, k, 0x400, hbitmap, IntPtr.Zero);
                    }
                }
            }
            uint maxValue = uint.MaxValue;

            if (menu.MenuItems.Count > 0)
            {
                maxValue = PInvoke.TrackPopupMenu(menu.Handle, 0x180, pnt.X, pnt.Y, 0, pDropDownHandle, IntPtr.Zero);
                if (maxValue != 0)
                {
                    for (int m = 0; m < menu.MenuItems.Count; m++)
                    {
                        if (maxValue == PInvoke.GetMenuItemID(menu.Handle, m))
                        {
                            name = menu.MenuItems[m].Name;
                            break;
                        }
                    }
                }
            }
            menu.Dispose();
            if (!QTUtility.IsXP)
            {
                foreach (IntPtr ptr2 in list)
                {
                    PInvoke.DeleteObject(ptr2);
                }
            }
            if (maxValue != 0)
            {
                return(name);
            }
            return(null);
        }