Praeclarum.UI.DocumentsViewController.RemoveDocuments C# (CSharp) Method

RemoveDocuments() public method

public RemoveDocuments ( string paths, bool animated ) : void
paths string
animated bool
return void
		public void RemoveDocuments (string[] paths, bool animated)
		{
			List<int> indices = new List<int> ();
			foreach (var path in paths) {
				var docIndex = Docs.FindIndex (x => x.File.Path == path);

				if (docIndex < 0 || docIndex >= Docs.Count)
					return;

				indices.Add (docIndex);
			}

			indices.Sort ();
			var offset = 0;

			foreach (var docIndex in indices) {
				Docs.RemoveAt (docIndex - offset);
				items.RemoveAt (docIndex - offset);
				offset++;
			}

			docsView.DeleteItems (indices.ToArray(), animated);
		}

Usage Example

		async Task MoveDoc (IFile file, DocumentsViewController listC, IFileSystem dest, string destDir, bool animated)
		{
			await ActiveFileSystem.MoveAsync (file, dest, destDir);
			listC.RemoveDocuments (new[]{file.Path}, animated);
		}