private void DocumentOnFilePathChanged(object o, GH_DocFilePathEventArgs ghDocFilePathEventArgs) { ExpireSolution(true); if (string.IsNullOrWhiteSpace(ghDocFilePathEventArgs.OldFilePath) || string.IsNullOrWhiteSpace(ghDocFilePathEventArgs.NewFilePath)) { return; } if (ghDocFilePathEventArgs.OldFilePath == ghDocFilePathEventArgs.NewFilePath) { return; } var oldDir = new DirectoryInfo(Path.GetDirectoryName(ghDocFilePathEventArgs.OldFilePath)); var newDir = new DirectoryInfo(Path.GetDirectoryName(ghDocFilePathEventArgs.NewFilePath)); var scriptFile = new FileInfo(ghDocFilePathEventArgs.NewFilePath); try { var files = _patterns.SelectMany(x => oldDir.EnumerateFiles(x)).Where(x => x.Name != scriptFile.Name).ToList(); foreach (var fileInfo in files) { fileInfo.CopyTo(Path.Combine(newDir.FullName, fileInfo.Name)); } } catch (Exception e) { // } }
/// <summary> /// Method that is called when the file path of the document changed. This will remove the /// object manager of the old document /file since the object manangers are created based on the /// GH document ID and the file path. /// </summary> /// <param name="sender"> The object that raises the event. </param> /// <param name="e"> The event data. </param> private static void OnFilePathChanged(object sender, GH_DocFilePathEventArgs e) { // Remove the old object manager (id is changed) string oldId = DocumentManager.GetRobotComponentsDocumentID(e.Document, e.OldFilePath); if (ObjectManagers.ContainsKey(oldId)) { ObjectManagers.Remove(oldId); } }
private void DocumentOnFilePathChanged(object o, GH_DocFilePathEventArgs ghDocFilePathEventArgs) { ExpireSolution(true); }