protected RmlSlidePanel(LoadInfo info) : base(info) { if (info.Version < 2) { InlineRmlUpgradeCache.setRml(this, info.GetString("rml", null)); rmlFile = Guid.NewGuid().ToString("D") + ".rml"; } }
public override object restoreObject(LoadInfo info) { Slide slide = (Slide)base.restoreObject(info); //Scan the loadInfo and see if there is anything we need to upgrade. if (info.hasValue("rml")) { RmlSlidePanel panel = new RmlSlidePanel(); InlineRmlUpgradeCache.setRml(panel, info.GetString("rml")); panel.ElementName = new BorderLayoutElementName(GUILocationNames.ContentArea, BorderLayoutLocations.Left); panel.Size = 480; slide.addPanel(panel); } if (info.hasValue("layers")) { slide.StartupAction = new SetupSceneAction("Show", info.GetValue <CameraPosition>("cameraPosition", null), info.GetValue <LayerState>("layers", null), info.GetValue <MusclePosition>("musclePosition", null), info.GetValue <PresetState>("medicalState", null), true, false); } return(slide); }
public override void clicked(TaskPositioner taskPositioner) { if (Plugin.AtlasPluginManager.allDependenciesLoadedFor(this.Plugin)) { VirtualFilesystemResourceProvider resourceProvider = new VirtualFilesystemResourceProvider(Plugin.PluginRootFolder); try { Slideshow slideshow; using (Stream stream = resourceProvider.openFile(SlideshowFile)) { slideshow = SharedXmlSaver.Load <Slideshow>(stream); } if (slideshow.Version == Slideshow.CurrentVersion) { AnomalousMvcContext context = slideshow.createContext(resourceProvider, Plugin.GuiManager); context.RuntimeName = UniqueName; context.setResourceProvider(resourceProvider); Plugin.TimelineController.setResourceProvider(resourceProvider); Plugin.MvcCore.startRunningContext(context); } else { MessageBox.show(String.Format("Cannot run slideshow \"{0}.\" It was created in a different version of Anomalous Medical.\nYou will need to download an updated version.", Name), "Error", MessageBoxStyle.IconError | MessageBoxStyle.Ok); InlineRmlUpgradeCache.removeSlideshowPanels(slideshow); } } catch (Exception ex) { Log.Error("Cannot load context '{0}'\nReason: {1}", SlideshowFile, ex.Message); } } else { MessageBox.show("Additional files needed to run this task. Would you like to download them now?", "Files Needed", MessageBoxStyle.IconQuest | MessageBoxStyle.Yes | MessageBoxStyle.No, result => { if (result == MessageBoxStyle.Yes) { Plugin.AtlasPluginManager.requestDependencyDownloadFor(this.Plugin); } }); } }
protected internal override void updateToVersion(int fromVersion, int toVersion, Slide slide, ResourceProvider slideshowResources) { if (toVersion >= 2 && fromVersion < toVersion) { String rml; if (InlineRmlUpgradeCache.tryGetValue(this, out rml)) { rml = rml.Replace(Version1TemplateLink, Version2TemplateLinkReplacement); InlineRmlUpgradeCache.setRml(this, rml); } using (Stream stream = slideshowResources.openWriteStream(Path.Combine(slide.UniqueName, Slide.StyleSheetName))) { } } if (toVersion >= 3 && fromVersion < toVersion) { String rml; if (InlineRmlUpgradeCache.tryGetValue(this, out rml)) { using (StreamWriter writer = new StreamWriter(slideshowResources.openWriteStream(getRmlFilePath(slide)), Encoding.UTF8)) { writer.Write(rml); } } } }