//Adds shortcut into the listview private void AddItem(ShortcutItem item) { Icon icn = null; //Load icon from path. If empty, try use the icons in the mappings if (string.IsNullOrEmpty(item.IconPath)) { string strApplicationPart = CommonUtil.GetApplicationPart(item.Application); if (System.IO.Directory.Exists(strApplicationPart)) { //folder icn = IconMapperUtil.GetDefaultIcon("folder"); } else { //get the default icons string strExt = System.IO.Path.GetExtension(strApplicationPart).ToLower(); icn = IconMapperUtil.GetDefaultIcon(strExt); } } else { //Find in the icon folder first. if it exists, use it if (System.IO.File.Exists(AppConfig.GetIconMapFile(item.IconPath))) { icn = CommonUtil.GetIcon(AppConfig.GetIconMapFile(item.IconPath)); } //Locate the physical file directly. If exists, use it else if (System.IO.File.Exists(item.IconPath)) { icn = CommonUtil.GetIcon(item.IconPath); } //Use default icon else { string strExt = System.IO.Path.GetExtension(item.Application).ToLower(); icn = IconMapperUtil.GetDefaultIcon(strExt); } } //Add item to list so that it is viewable in the list imageList1.Images.Add(icn); //create listview item ListViewItem l = new ListViewItem(); l.ImageIndex = imageList1.Images.Count - 1; l.Text = item.Text; // +"\n" + item.strApplication; l.Name = Guid.NewGuid().ToString(); l.ToolTipText = item.Application; l.Tag = item; l.Group = lvSearchResult.Groups[item.GroupName]; //Add list view item lvSearchResult.Items.Add(l); }
//save the default icon mapping tab settings private void SaveTabDefaultIconMappings() { DataTable dt = (DataTable)dgvDefaultIconMapping.DataSource; IconMapperUtil.UpdateIconMapping(dt); }
//Loads the default icon mapping tab private void LoadTabDefaultIconsMappings() { dgvDefaultIconMapping.DataSource = IconMapperUtil.GetIconMapDataTable(); }