Bloom.Publish.PublishModel.GetExtensionMenuItems C# (CSharp) Method

GetExtensionMenuItems() public method

public GetExtensionMenuItems ( ) : IEnumerable
return IEnumerable
        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", _collectionSettings.Language1Iso639Code);
                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>();
            }
        }

Usage Example

Example #1
0
        private void Activate()
        {
            _activated = false;
            PublishHelper.InPublishTab = true;

            Logger.WriteEvent("Entered Publish Tab");
            if (IsMakingPdf)
            {
                return;
            }


//			_model.BookletPortion = PublishModel.BookletPortions.BookletPages;


            _model.RefreshValuesUponActivation();

            //reload items from extension(s), as they may differ by book (e.g. if the extension comes from the template of the book)
            var toolStripItemCollection = new List <ToolStripItem>(from ToolStripItem x in _contextMenuStrip.Items select x);

            foreach (ToolStripItem item in toolStripItemCollection)
            {
                if (item.Tag == "extension")
                {
                    _contextMenuStrip.Items.Remove(item);
                }
            }
            foreach (var item in _model.GetExtensionMenuItems())
            {
                item.Tag = "extension";
                _contextMenuStrip.Items.Add(item);
            }

            // We choose not to remember the last state this tab might have been in.
            // Also since we don't know if the pdf is out of date, we assume it is, and don't show the prior pdf.
            // SetModelFromButtons takes care of both of these things for the model
            ClearRadioButtons();
            SetModelFromButtons();
            _model.DisplayMode = PublishModel.DisplayModes.WaitForUserToChooseSomething;

            UpdateDisplay();

            _activated = true;
        }