public override void OK() { if (_wereChanges) { _wereChanges = false; _folderList.DataProvider = null; Cursor current = Cursor.Current; Cursor.Current = Cursors.WaitCursor; try { FoldersCollection.Instance.Interrupted = true; FoldersCollection.Instance.WaitUntilFinished(); Core.ResourceAP.RunUniqueJob( "Modifying settings for Indexed File Folders", new MethodInvoker(SubmitChanges)); if (!IsStartupPane) { FoldersCollection.LoadFoldersForest(); } } finally { Cursor.Current = current; } } }
public override void Execute(IActionContext context) { IResource folder = context.SelectedResources[0]; if (folder.GetIntProp(FileProxy._propStatus) != _mode) { new ResourceProxy(folder).SetProp(FileProxy._propStatus, _mode); FoldersCollection.Instance.Interrupted = true; FoldersCollection.Instance.WaitUntilFinished(); FoldersCollection.LoadFoldersForest(); } }
public Icon GetResourceIcon(IResource resource) { if (resource.Type == _folderResourceType) { string directory = resource.GetPropText(_propDirectory); FoldersCollection instance = FoldersCollection.Instance; if (instance.IsPathDeferred(directory) || instance.IsPathMonitored(directory)) { return((resource.GetIntProp("Open") != 0) ? _openFolderIcon : _folderIcon); } return(_excludedFolderIcon); } return(null); }
private static void Core_StateChanged(object sender, EventArgs e) { if (Core.State == CoreState.Running) { _filesProcessor.StartThread(); _filesProcessor.ThreadPriority = ThreadPriority.BelowNormal; FoldersCollection.LoadFoldersForest(); } else if (Core.State == CoreState.ShuttingDown) { FoldersCollection.Instance.Interrupted = true; FoldersCollection.ProcessPendingFileDeletions(); } }
public override void OK() { string exts = _textExtsList.Text; if (exts.Length == 0) { exts = ".txt"; _wereChanges = true; } if (_wereChanges) { ISettingStore settings = Core.SettingStore; settings.WriteString("FilePlugin", "PlainTextExts", exts); settings.WriteBool("FilePlugin", "IndexHidden", _indexHiddenCheckBox.Checked); settings.WriteBool("FilePlugin", "ViewHidden", _viewHiddenCheckBox.Checked); if (!IsStartupPane) { FoldersCollection.Instance.Interrupted = true; FoldersCollection.Instance.WaitUntilFinished(); FoldersCollection.LoadFoldersForest(); } } }
public void Execute(IActionContext context) { IResourceList selected = context.SelectedResources; ArrayList names = new ArrayList(selected.Count); foreach (IResource res in selected.ValidResources) { string name = res.GetStringProp(FileProxy._propDirectory); if (res.Type != FileProxy._folderResourceType) { name = Path.Combine(name, res.GetPropText(Core.Props.Name)); } names.Add(name); } if (names.Count > 0) { IResourceBrowser rBrowser = Core.ResourceBrowser; IResourceList viewedResources = selected.Intersect(rBrowser.SelectedResources); IResource res2Select = null; foreach (IResource res in viewedResources.ValidResources) { res2Select = rBrowser.GetResourceBelow(res); } try { FoldersCollection foldersCollection = FoldersCollection.Instance; if (Control.ModifierKeys == Keys.Shift) { if (MessageBox.Show(Core.MainWindow, "Are you sure you want to delete " + ((names.Count > 1) ? (names.Count + " selected items?") : ("'" + names[0] + "'?")), "Confirm Deletion", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { foreach (IResource res in selected.ValidResources) { foldersCollection.DeleteResource(res); } foreach (string name in names) { if (File.Exists(name)) { File.Delete(name); } else if (Directory.Exists(name)) { Directory.Delete(name, true); } } } } else { Shell32.MoveFile2RecycleBin((string[])names.ToArray(typeof(string))); FileProxy._filesProcessor.QueueJob( new ResourceListDelegate(foldersCollection.EnumerateParents), selected); } } catch (Exception e) { Utils.DisplayException(e, "Error"); return; } if (res2Select != null) { rBrowser.SelectResource(res2Select); } } }
private static void ResourceNodeSelected(IResource res, bool displayAnotherFolder) { if (Core.State != CoreState.ShuttingDown && res.Type == _folderResourceType) { IResourceBrowser rBrowser = Core.ResourceBrowser; // for deleted folder display empty resource list if (res.IsDeleted) { rBrowser.DisplayResourceList( null, Core.ResourceStore.EmptyResourceList, res.DisplayName, null); return; } if (!displayAnotherFolder && res != rBrowser.OwnerResource) { return; } IResourceList selected = null; if (res == rBrowser.OwnerResource) { selected = rBrowser.SelectedResources; } FoldersCollection foldersCollection = FoldersCollection.Instance; string path = res.GetPropText(_propDirectory); IResourceList folderContents = res.GetLinksToLive(null, _propParentFolder); /** * look through folders, create new ones and delete obsolete */ DirectoryInfo[] dirs = IOTools.GetDirectories(path); if (dirs != null) { foreach (DirectoryInfo dir in dirs) { foldersCollection.FindOrCreateDirectory(dir.FullName); } HashSet fileNames = new HashSet(); bool viewHidden = Core.SettingStore.ReadBool("FilePlugin", "ViewHidden", false); foreach (IResource file in folderContents.ValidResources) { if (file.Type == _folderResourceType) { if (!Directory.Exists(file.GetPropText(_propDirectory))) { foldersCollection.DeleteResource(file); } } else { string fullname = foldersCollection.GetFullName(file); if (!File.Exists(fullname)) { foldersCollection.DeleteResource(file); } else { FileInfo fi = IOTools.GetFileInfo(fullname); if (viewHidden || (fi.Attributes & FileAttributes.Hidden) == 0) { fileNames.Add(file.GetPropText(Core.Props.Name)); } } } } /** * collect not indexed files */ FileInfo[] files = IOTools.GetFiles(path); if (files != null) { foreach (FileInfo fi in files) { if ((viewHidden || (fi.Attributes & FileAttributes.Hidden) == 0) && !fileNames.Contains(fi.Name)) { IResource file = foldersCollection.FindOrCreateFile(fi, true); if (file != null) { folderContents = folderContents.Union(file.ToResourceList(), true); } } } } } /** * for folders excluded from indexing display deleted resources as well */ if (FoldersCollection.Instance.IsPathDeferred(path) || FoldersCollection.Instance.IsPathMonitored(path)) { folderContents = folderContents.Minus( Core.ResourceStore.FindResourcesWithPropLive(null, _propDeletedFile)); } ColumnDescriptor[] fileColumns = new ColumnDescriptor[4]; fileColumns[0].PropNames = new[] { "DisplayName" }; fileColumns[0].Width = 300; fileColumns[0].CustomComparer = new FoldersUpComparer(); fileColumns[1].PropNames = new[] { "FileType" }; fileColumns[1].Width = 120; fileColumns[2].PropNames = new[] { "Size" }; fileColumns[2].Width = 120; fileColumns[3].PropNames = new[] { "Date" }; fileColumns[3].Width = 120; rBrowser.DisplayUnfilteredResourceList( res, folderContents, path, Core.DisplayColumnManager.AddAnyTypeColumns(fileColumns)); if (selected != null) { foreach (IResource file in selected.ValidResources) { rBrowser.SelectResource(file); } } } }