void OnCellEndEdit(object sender, LabelEditEventArgs e) { string newName = e.Label; if (e.CancelEdit || string.IsNullOrEmpty(newName)) { return; } ListViewItem row = this.Items[e.Item]; // rename code here CatalogItem ci = row.Tag as CatalogItem; if (ci != null) { if (String.Equals(ci.Name, newName, StringComparison.InvariantCultureIgnoreCase)) { return; } ci.Name = newName; ci.Save(); AddonHostForm masterForm = FindForm() as AddonHostForm; if (masterForm != null) { masterForm.ReloadNavigation(ci); } } }
private void ScanFile(Catalog cat, string file, CatalogItem parent) { if (!CanContinue()) { return; } ReportPseudoStepInit("TXT_SCANNING: " + file); try { CatalogItem ci = new CatalogItem(cat); ci.IsRoot = false; ci.ItemType = cat.CatalogItemType_GetByTypeCode("FIL").TypeID; // is a file ci.Name = Path.GetFileName(file); DriveInfo di = new DriveInfo(Path.GetPathRoot(file)); if (di.DriveType == DriveType.Removable || di.DriveType == DriveType.CDRom) { ci.OrigItemPath = file.Replace(Path.GetPathRoot(file), "$:/"); if (PathUtils.DirectorySeparator != "/") { ci.OrigItemPath = ci.OrigItemPath.Replace(PathUtils.DirectorySeparator, "/"); } } else { ci.OrigItemPath = file; } ci.RootItemLabel = di.VolumeLabel; ci.RootSerialNumber = Kernel32.GetVolumeSerialNumber(di.RootDirectory.FullName); ci.ParentItemID = parent.ItemID; try { NativeFileInfo nfi = NativeFileInfoFactory.FromPath(file); if (nfi != null) { ci.Description = nfi.Details; } } catch (Exception ex) { Logger.LogException(ex); } ci.Save(); RaiseTaskProgressEvent(null, _currentStep++); } catch (Exception ex) { ConfirmScanAbortOnException(ex); } Application.DoEvents(); }
public override void ShowProperties(List <string> strItems, object additionalData) { this.cat = additionalData as Catalog; this.strItems = strItems; pgProperties.SelectedObjects = null; if (cat != null) { lci = new List <object>(); // The objects in strItems are vpaths. foreach (string vpath in strItems) { if (vpath == Catalog.CatalogVPath) { cat.CatalogSchemaVersion = Translator.TranslateTaggedString(cat.CatalogSchemaVersion); pgProperties.SelectedObjects = new object[] { cat }; break; } else { CatalogItem ci = cat.GetByVPath(vpath); if (ci != null) { ci.Description = Translator.TranslateTaggedString(ci.Description).Replace("::", ":"); ci.ItemTypeDesc = Translator.TranslateTaggedString(ci.ItemTypeDesc); ci.Save(); lci.Add(ci); } } } } if (lci != null && lci.Count > 0) { FileAttributesBrowser.ProcessObjectAttributes(lci); pgProperties.SelectedObjects = lci.ToArray(); } }
public void ScanFolder(Catalog cat, string dir, CatalogItem parent) { if (!CanContinue()) { return; } ReportPseudoStepInit("TXT_SCANNING: " + dir); try { DriveInfo di = new DriveInfo(Path.GetPathRoot(dir)); CatalogItem ci = new CatalogItem(cat); if (di.DriveType == DriveType.Removable || di.DriveType == DriveType.CDRom) { ci.OrigItemPath = dir.Replace(Path.GetPathRoot(dir), "$:/"); if (PathUtils.DirectorySeparator != "/") { ci.OrigItemPath = ci.OrigItemPath.Replace(PathUtils.DirectorySeparator, "/"); } } else { ci.OrigItemPath = dir; } ci.IsRoot = (parent == null); ci.RootItemLabel = di.VolumeLabel; ci.RootSerialNumber = Kernel32.GetVolumeSerialNumber(di.RootDirectory.FullName); ci.Name = GetName(dir, di); if (parent != null) { ci.ParentItemID = parent.ItemID; } if (ci.IsRoot) { // This is a disk ci.ItemType = (byte)di.DriveType; ci.Description = EntryDescription; } else { ci.ItemType = cat.CatalogItemType_GetByTypeCode("FLD").TypeID; // is a folder } ci.Save(); Application.DoEvents(); List <string> subDirs = PathUtils.EnumDirectories(_abortScan, dir); foreach (string subDir in subDirs) { ScanFolder(cat, subDir, ci); } List <string> files = PathUtils.EnumFiles(_abortScan, dir); foreach (string file in files) { ScanFile(cat, file, ci); } RaiseTaskProgressEvent(null, _currentStep++); } catch (Exception ex) { ConfirmScanAbortOnException(ex); } }