public void cleanup() { //Cleanup slide trash CleanupInfo cleanupInfo = new CleanupInfo(); slideshow.cleanup(cleanupInfo, ResourceProvider); undoBuffer.clear(); //Can't really recover from this one, so just erase all undo List <Guid> cleanupSlides = new List <Guid>(projectGuidDirectories()); foreach (Slide slide in slideshow.Slides) { Guid guid; if (Guid.TryParse(slide.UniqueName, out guid)) { cleanupSlides.Remove(guid); } foreach (String file in ResourceProvider.listFiles("*", slide.UniqueName, true)) { if (!cleanupInfo.isClaimed(file)) { try { editorController.ResourceProvider.delete(file); } catch (Exception ex) { Logging.Log.Error("Cleanup -- Failed to delete file '{0}'. Reason: {1}", file, ex.Message); } } } } foreach (Guid dir in cleanupSlides) { try { editorController.ResourceProvider.delete(dir.ToString("D")); } catch (Exception ex) { Logging.Log.Error("Cleanup -- Failed to delete directory '{0}'. Reason: {1}", dir, ex.Message); } } PropFactory propFactory = standaloneController.PropFactory; DDAtlasPlugin plugin; using (Stream pluginFileStream = editorController.ResourceProvider.openFile("Plugin.ddp")) { plugin = SharedXmlSaver.Load <DDAtlasPlugin>(pluginFileStream); } plugin.setDependencyIds(cleanupInfo.getObjects <String>(ShowPropAction.PropClass) .Select(n => propFactory.getDependencyIdForProp(n)) .Where(id => id.HasValue) .Select(id => id.Value)); using (Stream pluginFileStream = editorController.ResourceProvider.openWriteStream("Plugin.ddp")) { SharedXmlSaver.Save(plugin, pluginFileStream); } }
private void saveSceneThumbInfo(Slide slide, SceneThumbInfo thumbInfo) { try { using (Stream stream = slideEditController.ResourceProvider.openWriteStream(slide.SceneThumbInfoName)) { SharedXmlSaver.Save(thumbInfo, stream); } saveThumbnail(slide.SceneThumbName, thumbInfo.SceneThumb); } catch (Exception ex) { Logging.Log.Error("{0} exception updating thumbnail info. Message: {1}", ex.GetType().Name, ex.Message); } }
void save_MouseButtonClick(Widget source, EventArgs e) { if (recordingSequence != null) { FileSaveDialog saveDialog = new FileSaveDialog(MainWindow.Instance, message: "Save Recorded Sequence", wildcard: "Movement Sequence (*.seq)|*.seq"); saveDialog.showModal((result, path) => { if (result == NativeDialogResult.OK) { using (Stream stream = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.None)) { SharedXmlSaver.Save(recordingSequence, stream); } } }); } }
public Bookmark loadBookmark(String bookmarkPath) { try { if (bookmarksResourceProvider != null && bookmarksResourceProvider.fileExists(bookmarkPath)) { using (var stream = bookmarksResourceProvider.openFile(bookmarkPath)) { return(SharedXmlSaver.Load <Bookmark>(stream)); } } } catch (Exception ex) { Logging.Log.Error("{0} loading bookmark '{1}'. Message: {2}", ex.GetType().Name, bookmarkPath, ex.Message); } return(null); }
/// <summary> /// Call this function to make a new scene thumbnail bitmap for a slide. /// </summary> /// <param name="slide"></param> /// <param name="fileNotFoundCallback">This function is called if the bitmap file is not found. It should return a bitmap that will have control taken by this class, it will be treated as an unsaved scene thumb, and will be disposed by this class.</param> /// <returns></returns> public SceneThumbInfo loadThumbSceneBitmap(Slide slide, Func <SceneThumbInfo> fileNotFoundCallback = null) { SceneThumbInfo thumb; if (!unsavedSceneThumbs.TryGetValue(slide, out thumb) && !savedSceneThumbCache.TryGetValue(slide, out thumb)) { String sceneThumbFile = slide.SceneThumbName; String sceneThumbInfoFile = slide.SceneThumbInfoName; if (slideEditController.ResourceProvider.fileExists(sceneThumbFile) && slideEditController.ResourceProvider.fileExists(sceneThumbInfoFile)) { using (Stream stream = slideEditController.ResourceProvider.openFile(sceneThumbInfoFile)) { thumb = SharedXmlSaver.Load <SceneThumbInfo>(stream); } using (Stream stream = slideEditController.ResourceProvider.openFile(sceneThumbFile)) { thumb.SceneThumb = new FreeImageBitmap(stream); } savedSceneThumbCache[slide] = thumb; } else { if (fileNotFoundCallback != null) { thumb = fileNotFoundCallback(); unsavedSceneThumbs.Add(slide, thumb); //Since we had to generate it, consider this an unsaved thumb, we also know for sure here that the thumb does not already exist } else { throw new FileNotFoundException(sceneThumbFile); } } } return(thumb); }