private void UpdateAllPackages() { if (!this.ConfirmCompatibility(this.packageManager.GetUpdatablePackages())) { return; } ProcessingBigTaskDialog setupDialog = new ProcessingBigTaskDialog( PackageManagerFrontendRes.TaskUpdatePackages_Caption, PackageManagerFrontendRes.TaskUpdatePackages_Desc, PackageUpdateAllThread, this.packageManager); setupDialog.MainThreadRequired = false; setupDialog.ShowDialog(); this.packageList.Invalidate(); this.modelInstalled.ApplyChanges(); this.modelOnline.ApplyChanges(); this.restartRequired = true; this.UpdateBottomButtons(); }
private void InstallPackage(PackageInfo info) { if (!this.ConfirmCompatibility(info)) { return; } bool anythingChanged = false; EventHandler <PackageEventArgs> listener = delegate(object sender, PackageEventArgs e) { anythingChanged = true; }; bool operationSuccessful = false; this.packageManager.PackageInstalled += listener; this.packageManager.PackageUninstalled += listener; { ProcessingBigTaskDialog setupDialog = new ProcessingBigTaskDialog( PackageManagerFrontendRes.TaskInstallPackages_Caption, PackageManagerFrontendRes.TaskInstallPackages_Desc, PackageOperationThread, new PackageOperationData(this.packageManager, info, d => d.Manager.InstallPackage(d.Package.Name))); setupDialog.MainThreadRequired = false; setupDialog.ShowDialog(); operationSuccessful = setupDialog.DialogResult == DialogResult.OK; } this.packageManager.PackageUninstalled -= listener; this.packageManager.PackageInstalled -= listener; if (anythingChanged) { this.packageList.Invalidate(); this.modelInstalled.ApplyChanges(); this.modelOnline.ApplyChanges(); this.restartRequired = operationSuccessful; this.UpdateBottomButtons(); } }
private void UpdatePackage(PackageInfo info) { if (!this.ConfirmCompatibility(info)) { return; } ProcessingBigTaskDialog setupDialog = new ProcessingBigTaskDialog( PackageManagerFrontendRes.TaskUpdatePackages_Caption, PackageManagerFrontendRes.TaskUpdatePackages_Desc, PackageOperationThread, new PackageOperationData(this.packageManager, info, d => d.Manager.UpdatePackage(d.Package))); setupDialog.MainThreadRequired = false; setupDialog.ShowDialog(); this.packageList.Invalidate(); this.modelInstalled.ApplyChanges(); this.modelOnline.ApplyChanges(); this.restartRequired = (setupDialog.DialogResult == DialogResult.OK); this.UpdateBottomButtons(); }
private static void ProcessDataDirEvents() { List <ResourceRenamedEventArgs> renameEventBuffer = null; // Process events while (dataDirEventBuffer.Count > 0) { FileSystemEventArgs e = FetchFileSystemEvent(dataDirEventBuffer, DualityApp.DataDirectory); if (e == null) { continue; } // Determine whether we're dealing with a directory bool isDirectory = Directory.Exists(e.FullPath); { // If this is a deletion, nothing exists anymore, rely on metadata instead. DeletedEventArgsExt de = e as DeletedEventArgsExt; if (de != null && de.IsDirectory) { isDirectory = true; } } if (e.ChangeType == WatcherChangeTypes.Changed) { // Ignore stuff saved by the editor itself if (IsPathEditorModified(e.FullPath)) { continue; } if (Resource.IsResourceFile(e.FullPath) || isDirectory) { ContentRef <Resource> resRef = new ContentRef <Resource>(null, e.FullPath); // Unregister outdated resources, if modified outside the editor if (!isDirectory && ContentProvider.HasContent(e.FullPath)) { bool isCurrentScene = resRef.Is <Scene>() && Scene.Current == resRef.Res; if (isCurrentScene || DualityEditorApp.IsResourceUnsaved(e.FullPath)) { DialogResult result = MessageBox.Show( String.Format(Properties.GeneralRes.Msg_ConfirmReloadResource_Text, e.FullPath), Properties.GeneralRes.Msg_ConfirmReloadResource_Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (result == DialogResult.Yes) { string curScenePath = Scene.CurrentPath; ContentProvider.RemoveContent(e.FullPath); if (isCurrentScene) { Scene.SwitchTo(ContentProvider.RequestContent <Scene>(curScenePath), true); } } } else { ContentProvider.RemoveContent(e.FullPath); } } if (ResourceModified != null) { ResourceModified(null, new ResourceEventArgs(e.FullPath, isDirectory)); } } } else if (e.ChangeType == WatcherChangeTypes.Created) { if (File.Exists(e.FullPath)) { // Register newly detected Resource file if (Resource.IsResourceFile(e.FullPath)) { if (ResourceCreated != null) { ResourceCreated(null, new ResourceEventArgs(e.FullPath, false)); } } // Import non-Resource file else { bool abort = false; if (FileImportProvider.DoesImportOverwriteData(e.FullPath)) { DialogResult result = MessageBox.Show( String.Format(Properties.GeneralRes.Msg_ImportConfirmOverwrite_Text, e.FullPath), Properties.GeneralRes.Msg_ImportConfirmOverwrite_Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Warning); abort = result == DialogResult.No; } if (!abort) { bool importedSuccessfully = FileImportProvider.ImportFile(e.FullPath); if (!importedSuccessfully) { MessageBox.Show( String.Format(Properties.GeneralRes.Msg_CantImport_Text, e.FullPath), Properties.GeneralRes.Msg_CantImport_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } abort = !importedSuccessfully; } } } else if (Directory.Exists(e.FullPath)) { // Register newly detected Resource directory if (ResourceCreated != null) { ResourceCreated(null, new ResourceEventArgs(e.FullPath, true)); } } } else if (e.ChangeType == WatcherChangeTypes.Deleted) { // Is it a Resource file or just something else? if (Resource.IsResourceFile(e.FullPath) || isDirectory) { ResourceEventArgs args = new ResourceEventArgs(e.FullPath, isDirectory); // Organize the Source/Media directory accordingly DeleteSourceMediaFile(args); // Unregister no-more existing resources if (isDirectory) { ContentProvider.RemoveContentTree(args.Path); } else { ContentProvider.RemoveContent(args.Path); } if (ResourceDeleted != null) { ResourceDeleted(null, args); } } } else if (e.ChangeType == WatcherChangeTypes.Renamed) { // Is it a Resource file or just something else? RenamedEventArgs re = e as RenamedEventArgs; ResourceRenamedEventArgs args = new ResourceRenamedEventArgs(re.FullPath, re.OldFullPath, isDirectory); if (Resource.IsResourceFile(e.FullPath) || isDirectory) { // Rename content registerations if (isDirectory) { ContentProvider.RenameContentTree(args.OldPath, args.Path); } else { ContentProvider.RenameContent(args.OldPath, args.Path); } // Query skipped paths bool isEmptyDir = isDirectory && !Directory.EnumerateFileSystemEntries(args.Path).Any(); bool isSkippedPath = isEmptyDir; if (!isSkippedPath && BeginGlobalRename != null) { BeginGlobalRenameEventArgs beginGlobalRenameArgs = new BeginGlobalRenameEventArgs(args.Path, args.OldPath, isDirectory); BeginGlobalRename(null, beginGlobalRenameArgs); isSkippedPath = beginGlobalRenameArgs.Cancel; } if (!isSkippedPath) { // Buffer rename event to perform the global rename for all at once. if (renameEventBuffer == null) { renameEventBuffer = new List <ResourceRenamedEventArgs>(); } renameEventBuffer.Add(args); } if (ResourceRenamed != null) { ResourceRenamed(null, args); } if (!isSkippedPath) { // Organize the Source/Media directory accordingly MoveSourceMediaFile(args); } } } } // If required, perform a global rename operation in all existing content if (renameEventBuffer != null) { // Don't do it now - schedule it for the main form event loop so we don't block here. DualityEditorApp.MainForm.BeginInvoke((Action) delegate() { ProcessingBigTaskDialog taskDialog = new ProcessingBigTaskDialog( Properties.GeneralRes.TaskRenameContentRefs_Caption, Properties.GeneralRes.TaskRenameContentRefs_Desc, async_RenameContentRefs, renameEventBuffer); taskDialog.ShowDialog(DualityEditorApp.MainForm); }); } }
private static void Main(string[] args) { // Parse command line arguments bool recover = false; foreach (string a in args) { if (a == "debug") { System.Diagnostics.Debugger.Launch(); } else if (a == "recover") { recover = true; } } // Culture setup Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; // Set up file logging StreamWriter logfileWriter = null; TextWriterLogOutput logfileOutput = null; try { // If there is an existing logfile, preserve it under a different name if (File.Exists(DualityEditorApp.EditorLogfilePath)) { if (File.Exists(DualityEditorApp.EditorPrevLogfilePath)) { File.Delete(DualityEditorApp.EditorPrevLogfilePath); } File.Move(DualityEditorApp.EditorLogfilePath, DualityEditorApp.EditorPrevLogfilePath); } // Create a new logfile logfileWriter = new StreamWriter(DualityEditorApp.EditorLogfilePath); logfileWriter.AutoFlush = true; logfileOutput = new TextWriterLogOutput(logfileWriter); Log.AddGlobalOutput(logfileOutput); } catch (Exception e) { Log.Core.WriteWarning("Text Logfile unavailable: {0}", Log.Exception(e)); } // Winforms Setup Application.CurrentCulture = Thread.CurrentThread.CurrentCulture; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.ThreadException += Application_ThreadException; { PackageManager packageManager = new PackageManager(); // On the first install startup, display a generic license agreement for Duality if (packageManager.IsFirstInstall) { LicenseAcceptDialog licenseDialog = new LicenseAcceptDialog { DescriptionText = GeneralRes.LicenseAcceptDialog_FirstStartGeneric, LicenseUrl = new Uri(DualityMainLicenseUrl) }; DialogResult result = licenseDialog.ShowDialog(); if (result != DialogResult.OK) { Application.Exit(); return; } } // Perform the initial package update - even before initializing the editor if (packageManager.IsPackageSyncRequired) { Log.Editor.Write("Updating Packages..."); Log.Editor.PushIndent(); ProcessingBigTaskDialog setupDialog = new ProcessingBigTaskDialog( GeneralRes.TaskInstallPackages_Caption, GeneralRes.TaskInstallPackages_Desc, SynchronizePackages, packageManager); setupDialog.ShowInTaskbar = true; setupDialog.MainThreadRequired = false; setupDialog.ShowDialog(); Log.Editor.PopIndent(); } if (packageManager.ApplyUpdate()) { Application.Exit(); return; } } // Run the editor SplashScreen splashScreen = new SplashScreen(recover); splashScreen.Show(); Application.Run(); // Clean up the log file if (logfileWriter != null) { Log.RemoveGlobalOutput(logfileOutput); logfileWriter.Flush(); logfileWriter.Close(); logfileWriter = null; logfileOutput = null; } }
private static void HandleDataDirEvents(FileEventQueue eventQueue) { // Gather a list of all externally modified resources that are currently loaded. // We'll use this to later tell the editor about the changes we've applied. List <Resource> modifiedLoadedResources = null; foreach (FileEvent fileEvent in eventQueue.Items) { if (fileEvent.IsDirectory) { continue; } // We're only interested in the path where we would find the Resource right now, // because we need the instance for the change notification string contentPath = (fileEvent.Type == FileEventType.Renamed) ? fileEvent.OldPath : fileEvent.Path; ContentRef <Resource> content = new ContentRef <Resource>(contentPath); // Some editor modules rely on change notifications to re-establish links to previously // removed Resources. In order to do that, we'll speculatively load newly arrived Resources // so we can put out a change notification for them. // Note: If ObjectSelection supported ContentRefs, we could improve and do that without the // speculative load, triggering a load only when someone was actually interested. if (content.IsLoaded || fileEvent.Type == FileEventType.Created) { if (modifiedLoadedResources == null) { modifiedLoadedResources = new List <Resource>(); } modifiedLoadedResources.Add(content.Res); } } // Handle each event according to its type List <FileEvent> renameEventBuffer = null; HashSet <string> sourceMediaDeleteSchedule = null; foreach (FileEvent fileEvent in eventQueue.Items) { if (fileEvent.Type == FileEventType.Changed) { HandleDataDirChangeEvent(fileEvent); } else if (fileEvent.Type == FileEventType.Deleted) { HandleDataDirDeleteEvent(fileEvent, ref sourceMediaDeleteSchedule); } else if (fileEvent.Type == FileEventType.Renamed) { HandleDataDirRenameEvent(fileEvent, ref renameEventBuffer); } } // If we scheduled source / media files for deletion, do it now at once if (sourceMediaDeleteSchedule != null) { // Gather a list of directories from which we're removing HashSet <string> affectedDirectories = new HashSet <string>(); foreach (string file in sourceMediaDeleteSchedule) { affectedDirectories.Add(Path.GetDirectoryName(file)); } // Send all the files to the recycle bin RecycleBin.SendSilent(sourceMediaDeleteSchedule); // Remove directories that are now empty foreach (string dir in affectedDirectories) { PathHelper.DeleteEmptyDirectory(dir, true); } } // If required, perform a global rename operation in all existing content if (renameEventBuffer != null) { // Don't do it now - schedule it for the main form event loop so we don't block here. DualityEditorApp.MainForm.BeginInvoke((Action) delegate() { ProcessingBigTaskDialog taskDialog = new ProcessingBigTaskDialog( Properties.GeneralRes.TaskRenameContentRefs_Caption, Properties.GeneralRes.TaskRenameContentRefs_Desc, async_RenameContentRefs, renameEventBuffer); taskDialog.ShowDialog(DualityEditorApp.MainForm); }); } // Notify the editor about externally modified resources if (modifiedLoadedResources != null) { DualityEditorApp.NotifyObjPropChanged( null, new ObjectSelection(modifiedLoadedResources), false); } }
private static void ProcessDataDirEvents() { List <ResourceRenamedEventArgs> renameEventBuffer = null; // Process events while (dataDirEventBuffer.Count > 0) { FileSystemEventArgs e = FetchFileSystemEvent(dataDirEventBuffer, dataDirWatcher.Path); if (e == null) { continue; } if (e.ChangeType == WatcherChangeTypes.Changed) { ResourceEventArgs args = new ResourceEventArgs(e.FullPath); bool justSaved = editorJustSavedRes.Contains(Path.GetFullPath(e.FullPath)); // Ignore stuff saved by the editor itself if (!justSaved && (Resource.IsResourceFile(e.FullPath) || args.IsDirectory)) { // Unregister outdated resources, if modified outside the editor if (!args.IsDirectory && ContentProvider.IsContentAvailable(args.Path)) { bool isCurrentScene = args.Content.Is <Scene>() && Scene.Current == args.Content.Res; if (isCurrentScene || DualityEditorApp.IsResourceUnsaved(e.FullPath)) { DialogResult result = MessageBox.Show( String.Format(EditorRes.GeneralRes.Msg_ConfirmReloadResource_Text, e.FullPath), EditorRes.GeneralRes.Msg_ConfirmReloadResource_Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (result == DialogResult.Yes) { string curScenePath = Scene.CurrentPath; ContentProvider.RemoveContent(args.Path); if (isCurrentScene) { Scene.Current = ContentProvider.RequestContent <Scene>(curScenePath).Res; } } } else { ContentProvider.RemoveContent(args.Path); } } if (ResourceModified != null) { ResourceModified(null, args); } } } else if (e.ChangeType == WatcherChangeTypes.Created) { if (File.Exists(e.FullPath)) { // Register newly detected ressource file if (Resource.IsResourceFile(e.FullPath)) { if (ResourceCreated != null) { ResourceCreated(null, new ResourceEventArgs(e.FullPath)); } } // Import non-ressource file else { bool abort = false; if (FileImportProvider.IsImportFileExisting(e.FullPath)) { DialogResult result = MessageBox.Show( String.Format(EditorRes.GeneralRes.Msg_ImportConfirmOverwrite_Text, e.FullPath), EditorRes.GeneralRes.Msg_ImportConfirmOverwrite_Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Warning); abort = result == DialogResult.No; } if (!abort) { bool importedSuccessfully = FileImportProvider.ImportFile(e.FullPath); if (!importedSuccessfully) { MessageBox.Show( String.Format(EditorRes.GeneralRes.Msg_CantImport_Text, e.FullPath), EditorRes.GeneralRes.Msg_CantImport_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } abort = !importedSuccessfully; } } } else if (Directory.Exists(e.FullPath)) { // Register newly detected ressource directory if (ResourceCreated != null) { ResourceCreated(null, new ResourceEventArgs(e.FullPath)); } } } else if (e.ChangeType == WatcherChangeTypes.Deleted) { // Is it a Resource file or just something else? ResourceEventArgs args = new ResourceEventArgs(e.FullPath); if (Resource.IsResourceFile(e.FullPath) || args.IsDirectory) { // Unregister no-more existing resources if (args.IsDirectory) { ContentProvider.RemoveContentTree(args.Path); } else { ContentProvider.RemoveContent(args.Path); } if (ResourceDeleted != null) { ResourceDeleted(null, args); } } } else if (e.ChangeType == WatcherChangeTypes.Renamed) { // Is it a Resource file or just something else? RenamedEventArgs re = e as RenamedEventArgs; ResourceRenamedEventArgs args = new ResourceRenamedEventArgs(re.FullPath, re.OldFullPath); if (Resource.IsResourceFile(e.FullPath) || args.IsDirectory) { // Rename content registerations if (args.IsDirectory) { ContentProvider.RenameContentTree(args.OldPath, args.Path); } else { ContentProvider.RenameContent(args.OldPath, args.Path); } // Query skipped paths bool isSkippedPath = false; if (BeginGlobalRename != null) { BeginGlobalRenameEventArgs beginGlobalRenameArgs = new BeginGlobalRenameEventArgs(args.Path, args.OldPath); BeginGlobalRename(null, beginGlobalRenameArgs); isSkippedPath = beginGlobalRenameArgs.Cancel; } if (!isSkippedPath) { // Buffer rename event to perform the global rename for all at once. if (renameEventBuffer == null) { renameEventBuffer = new List <ResourceRenamedEventArgs>(); } renameEventBuffer.Add(args); } if (ResourceRenamed != null) { ResourceRenamed(null, args); } } } } // If required, perform a global rename operation in all existing content if (renameEventBuffer != null) { // Don't do it now - schedule it for the main form event loop so we don't block here. DualityEditorApp.MainForm.BeginInvoke((Action) delegate() { ProcessingBigTaskDialog taskDialog = new ProcessingBigTaskDialog( EditorRes.GeneralRes.TaskRenameContentRefs_Caption, EditorRes.GeneralRes.TaskRenameContentRefs_Desc, async_RenameContentRefs, renameEventBuffer); taskDialog.ShowDialog(DualityEditorApp.MainForm); }); } }
private static void Main(string[] args) { // Parse command line arguments bool recover = false; foreach (string a in args) { if (a == "debug") { System.Diagnostics.Debugger.Launch(); } else if (a == "recover") { recover = true; } } // Culture setup Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; Application.CurrentCulture = Thread.CurrentThread.CurrentCulture; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.ThreadException += Application_ThreadException; { PackageManager packageManager = new PackageManager(); // On the first install startup, display a generic license agreement for Duality if (packageManager.IsFirstInstall) { LicenseAcceptDialog licenseDialog = new LicenseAcceptDialog { DescriptionText = GeneralRes.LicenseAcceptDialog_FirstStartGeneric, LicenseUrl = new Uri(DualityMainLicenseUrl) }; DialogResult result = licenseDialog.ShowDialog(); if (result != DialogResult.OK) { Application.Exit(); return; } } // Perform the initial package update - even before initializing the editor if (packageManager.IsPackageUpdateRequired) { Log.Editor.Write("Updating Packages..."); Log.Editor.PushIndent(); ProcessingBigTaskDialog setupDialog = new ProcessingBigTaskDialog( GeneralRes.TaskInstallPackages_Caption, GeneralRes.TaskInstallPackages_Desc, FirstTimeSetup, packageManager); setupDialog.ShowInTaskbar = true; setupDialog.MainThreadRequired = false; setupDialog.ShowDialog(); Log.Editor.PopIndent(); } if (packageManager.ApplyUpdate()) { Application.Exit(); return; } } // Run the editor SplashScreen splashScreen = new SplashScreen(recover); splashScreen.Show(); Application.Run(); }
private static void ProcessDataDirEvents() { List <ResourceRenamedEventArgs> renameEventBuffer = null; HashSet <string> sourceMediaDeleteSchedule = null; // Process events while (dataDirEventBuffer.Count > 0) { FileSystemEventArgs e = FetchFileSystemEvent(dataDirEventBuffer, DualityApp.DataDirectory); if (e == null) { continue; } // Determine whether we're dealing with a directory bool isDirectory = Directory.Exists(e.FullPath); { // If this is a deletion, nothing exists anymore, rely on metadata instead. DeletedEventArgsExt de = e as DeletedEventArgsExt; if (de != null && de.IsDirectory) { isDirectory = true; } } if (e.ChangeType == WatcherChangeTypes.Changed) { // Ignore stuff saved by the editor itself if (IsPathEditorModified(e.FullPath)) { continue; } if (Resource.IsResourceFile(e.FullPath) || isDirectory) { ContentRef <Resource> resRef = new ContentRef <Resource>(null, e.FullPath); // Unregister outdated resources, if modified outside the editor if (!isDirectory && ContentProvider.HasContent(e.FullPath)) { bool isCurrentScene = resRef.Is <Scene>() && Scene.Current == resRef.Res; if (isCurrentScene || DualityEditorApp.IsResourceUnsaved(e.FullPath)) { DialogResult result = MessageBox.Show( String.Format(Properties.GeneralRes.Msg_ConfirmReloadResource_Text, e.FullPath), Properties.GeneralRes.Msg_ConfirmReloadResource_Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (result == DialogResult.Yes) { string curScenePath = Scene.CurrentPath; ContentProvider.RemoveContent(e.FullPath); if (isCurrentScene) { Scene.SwitchTo(ContentProvider.RequestContent <Scene>(curScenePath), true); } } } else { ContentProvider.RemoveContent(e.FullPath); } } if (ResourceModified != null) { ResourceModified(null, new ResourceEventArgs(e.FullPath, isDirectory)); } } } else if (e.ChangeType == WatcherChangeTypes.Created) { if (File.Exists(e.FullPath)) { // Register newly detected Resource file if (Resource.IsResourceFile(e.FullPath)) { if (ResourceCreated != null) { ResourceCreated(null, new ResourceEventArgs(e.FullPath, false)); } } } else if (Directory.Exists(e.FullPath)) { // Register newly detected Resource directory if (ResourceCreated != null) { ResourceCreated(null, new ResourceEventArgs(e.FullPath, true)); } } } else if (e.ChangeType == WatcherChangeTypes.Deleted) { // Is it a Resource file or just something else? if (Resource.IsResourceFile(e.FullPath) || isDirectory) { ResourceEventArgs args = new ResourceEventArgs(e.FullPath, isDirectory); // Schedule Source/Media file deletion to keep it organized / synced with Resource Data if (sourceMediaDeleteSchedule == null) { sourceMediaDeleteSchedule = new HashSet <string>(); } GetDeleteSourceMediaFilePaths(args, sourceMediaDeleteSchedule); // Unregister no-more existing resources if (isDirectory) { ContentProvider.RemoveContentTree(args.Path); } else { ContentProvider.RemoveContent(args.Path); } if (ResourceDeleted != null) { ResourceDeleted(null, args); } } } else if (e.ChangeType == WatcherChangeTypes.Renamed) { // Is it a Resource file or just something else? RenamedEventArgs re = e as RenamedEventArgs; ResourceRenamedEventArgs args = new ResourceRenamedEventArgs(re.FullPath, re.OldFullPath, isDirectory); if (Resource.IsResourceFile(e.FullPath) || isDirectory) { // Determine which Source / Media files would belong to this Resource - before moving it string[] oldMediaPaths = PreMoveSourceMediaFile(args);; // Rename content registerations if (isDirectory) { ContentProvider.RenameContentTree(args.OldPath, args.Path); } else { ContentProvider.RenameContent(args.OldPath, args.Path); } // Query skipped paths bool isEmptyDir = isDirectory && !Directory.EnumerateFileSystemEntries(args.Path).Any(); bool isSkippedPath = isEmptyDir; if (!isSkippedPath && BeginGlobalRename != null) { BeginGlobalRenameEventArgs beginGlobalRenameArgs = new BeginGlobalRenameEventArgs(args.Path, args.OldPath, isDirectory); BeginGlobalRename(null, beginGlobalRenameArgs); isSkippedPath = beginGlobalRenameArgs.Cancel; } if (!isSkippedPath) { // Buffer rename event to perform the global rename for all at once. if (renameEventBuffer == null) { renameEventBuffer = new List <ResourceRenamedEventArgs>(); } renameEventBuffer.Add(args); } if (ResourceRenamed != null) { ResourceRenamed(null, args); } if (!isSkippedPath) { // Organize the Source/Media directory accordingly MoveSourceMediaFile(args, oldMediaPaths); } } } } // If we scheduled source / media files for deletion, do it now at once if (sourceMediaDeleteSchedule != null) { // Gather a list of directories from which we're removing HashSet <string> affectedDirectories = new HashSet <string>(); foreach (string file in sourceMediaDeleteSchedule) { affectedDirectories.Add(Path.GetDirectoryName(file)); } // Send all the files to the recycle bin RecycleBin.SendSilent(sourceMediaDeleteSchedule); // Remove directories that are now empty foreach (string dir in affectedDirectories) { PathHelper.DeleteEmptyDirectory(dir, true); } } // If required, perform a global rename operation in all existing content if (renameEventBuffer != null) { // Don't do it now - schedule it for the main form event loop so we don't block here. DualityEditorApp.MainForm.BeginInvoke((Action) delegate() { ProcessingBigTaskDialog taskDialog = new ProcessingBigTaskDialog( Properties.GeneralRes.TaskRenameContentRefs_Caption, Properties.GeneralRes.TaskRenameContentRefs_Desc, async_RenameContentRefs, renameEventBuffer); taskDialog.ShowDialog(DualityEditorApp.MainForm); }); } }