/// <summary> /// 将快捷的文件添加到托盘右键菜单中 /// </summary> private void FlushTrayChildMenuInLove() { this.smallIconImageList = new ImageList() { ImageSize = new Size(16, 16), ColorDepth = ColorDepth.Depth32Bit }; IList <BoxFile> boxFiles = new List <BoxFile>(); boxFiles = BoxFileData.getLikeShortcuts(); if (boxFiles != null && boxFiles.Count > 0) { ToolStripMenuItem toolStripMenuItem; BoxFile boxFileItem; for (int i = 0; i < boxFiles.Count; i++) { boxFileItem = boxFiles[i]; this.smallIconImageList.Images.Add(boxFileItem.SmallIcon); toolStripMenuItem = new ToolStripMenuItem(); toolStripMenuItem.Text = boxFileItem.Name; toolStripMenuItem.ToolTipText = boxFileItem.Name; toolStripMenuItem.Tag = boxFileItem; toolStripMenuItem.Image = this.smallIconImageList.Images[i]; toolStripMenuItem.Click += new EventHandler(toolStripSubMenu_Click); this.notifyContextMenuStrip.Items.Add(toolStripMenuItem); } boxFileItem = null; boxFiles = null; toolStripMenuItem = null; } }
/// <summary> /// 刷新快捷位置的图标 /// </summary> private void refreshLikeShortcut() { this.largeIconImageList = new ImageList() { ImageSize = new Size(32, 32), ColorDepth = ColorDepth.Depth32Bit }; this.smallIconImageList = new ImageList() { ImageSize = new Size(16, 16), ColorDepth = ColorDepth.Depth32Bit }; listViewLove.LargeImageList = largeIconImageList; listViewLove.SmallImageList = smallIconImageList; IList <BoxFile> boxFiles = BoxFileData.getLikeShortcuts(); ListViewItem listViewItem; BoxFile boxFileItem; listViewLove.Items.Clear(); if (boxFiles != null && boxFiles.Count > 0) { for (int i = 0; i < boxFiles.Count; i++) { boxFileItem = boxFiles[i]; this.largeIconImageList.Images.Add(boxFileItem.LargeIcon); this.smallIconImageList.Images.Add(boxFileItem.SmallIcon); listViewItem = new ListViewItem(); listViewItem.Text = boxFileItem.Name; listViewItem.Tag = boxFileItem; listViewItem.ImageIndex = i; listViewItem.SubItems.AddRange(new string[] { boxFileItem.Path }); listViewLove.Items.Add(listViewItem); } } }