This class currently just does one thing; it adds a right-click menu item in the Publish tab that saved PNG thumbnails of all the "day" pages of a SHRP Pupil's book. These are used in the corresponding "Teacher's Guide". It is built as an MEF "part", exporting what Bloom needs (the menu item) and importing what it needs (e.g. the contents of the book, an html thumbnailer) Currently (In Dec 2013), it isn't actually an extension because it doesn't have its own DLL. But it does demonstrate that we could trivially have extension dlls coming with templates, in separate DLLS. The key is keeping the dependences to a minimum so that extension don't break with each version of Bloom.
Ejemplo n.º 1
0
 public IEnumerable <ToolStripItem> GetExtensionMenuItems()
 {
     //for now we're not doing real extension dlls, just kind of faking it. So we will limit this load
     //to books we know go with this currently "built-in" "extension" for SIL LEAD's SHRP Project.
     if (SHRP_PupilBookExtension.ExtensionIsApplicable(BookSelection.CurrentSelection))
     {
         //load any extension assembly found in the template's root directory
         //var catalog = new DirectoryCatalog(this.BookSelection.CurrentSelection.FindTemplateBook().FolderPath, "*.dll");
         var catalog   = new AssemblyCatalog(Assembly.GetExecutingAssembly());
         var container = new CompositionContainer(catalog);
         //inject what we have to offer for the extension to consume
         container.ComposeExportedValue <string>("PathToBookFolder", BookSelection.CurrentSelection.FolderPath);
         container.ComposeExportedValue <string>("Language1Iso639Code", _currentlyLoadedBook.BookData.Language1.Iso639Code);
         container.ComposeExportedValue <Func <IEnumerable <HtmlDom> > >(GetPageDoms);
         //  container.ComposeExportedValue<Func<string>>("pathToPublishedHtmlFile",GetFileForPrinting);
         //get the original images, not compressed ones (just in case the thumbnails are, like, full-size & they want quality)
         container.ComposeExportedValue <Action <int, int, HtmlDom, Action <Image>, Action <Exception> > >(GetThumbnailAsync);
         container.SatisfyImportsOnce(this);
         return(_getExtensionMenuItems == null ? new List <ToolStripItem>() : _getExtensionMenuItems());
     }
     else
     {
         return(new List <ToolStripMenuItem>());
     }
 }
Ejemplo n.º 2
0
 public IEnumerable <ToolStripItem> GetExtensionMenuItems()
 {
     //for now we're not doing real extension dlls, just kind of faking it. So we will limit this load
     //to books we know go with this currently "built-in" "extension" for SIL LEAD's SHRP Project.
     //TODO: this should work, but it doesn't because BookInfo.BookLineage isn't working: if (SHRP_PupilBookExtension.ExtensionIsApplicable(BookSelection.CurrentSelection.BookInfo.BookLineage))
     if (SHRP_PupilBookExtension.ExtensionIsApplicable(BookSelection.CurrentSelection.GetBookLineage()))
     {
         //load any extension assembly found in the template's root directory
         //var catalog = new DirectoryCatalog(this.BookSelection.CurrentSelection.FindTemplateBook().FolderPath, "*.dll");
         var catalog   = new AssemblyCatalog(Assembly.GetExecutingAssembly());
         var container = new CompositionContainer(catalog);
         //inject what we have to offer for the extension to consume
         container.ComposeExportedValue <string>("PathToBookFolder", BookSelection.CurrentSelection.FolderPath);
         container.ComposeExportedValue <string>("Language1Iso639Code", _collectionSettings.Language1Iso639Code);
         container.ComposeExportedValue <Func <IEnumerable <HtmlDom> > >(GetPageDoms);
         //  container.ComposeExportedValue<Func<string>>("pathToPublishedHtmlFile",GetFileForPrinting);
         container.ComposeExportedValue <Action <int, int, HtmlDom, Action <Image>, Action <Exception> > >(GetThumbnailAsync);
         container.SatisfyImportsOnce(this);
         return(_getExtensionMenuItems == null ? new List <ToolStripItem>() : _getExtensionMenuItems());
     }
     else
     {
         return(new List <ToolStripMenuItem>());
     }
 }