コード例 #1
0
        /// <summary>
        /// Add a new set of resource information to the store.
        /// </summary>
        /// <param name="key">The unique id of the resource</param>
        /// <param name="elementName">Name of the element.</param>
        /// <param name="resourceString">A string of Xaml. Will be used to inflate on demand.</param>
        /// <param name="designerFileName">Name of the designer file.</param>
        /// <param name="uri">The URI.</param>
        internal void Add(string key, string elementName, string resourceString, string designerFileName, string uri)
        {
            var rd = new ResourceData(key, elementName, resourceString, designerFileName, uri);

            this.Add(rd);
        }
コード例 #2
0
        /// <summary>
        /// Populates any models from which Excel elements will be generated.
        /// TemplateFileName required for compatibility with legacy TempalteCollectio derrived maps.
        /// </summary>
        private void PopulateModels()
        {
            foreach (var item in this.ResourceDataDictionary)
            {
                ResourceData resourceData = item.Value;

                // Process ChartTemplate elements
                if (resourceData.ResourceType == "ChartTemplate")
                {
                    ChartTemplate chartTemplate = this.GetResourceByKey <ChartTemplate>(resourceData.Key);

                    if (chartTemplate != null)
                    {
                        WorksheetPart designerWorksheetPart = null;

                        // Get the worksheet on which the ChartTemplate resides (Alt. look at ExcelSheetMapper.GetDesignerWorksheet...)
                        var designerSpreadsheetDocument = GetDesignerSpreadsheetDocumentByKey(chartTemplate.Key);
                        if (designerSpreadsheetDocument != null)
                        {
                            designerWorksheetPart = designerSpreadsheetDocument.GetWorksheetPart(chartTemplate.TemplateSheetName);
                            if (designerWorksheetPart != null)
                            {
                                ExcelModel.ChartModel chartModel = ExcelModel.ChartModel.GetChartModel(designerWorksheetPart.Worksheet, chartTemplate.TemplateChartName);
                                if (chartModel != null)
                                {
                                    this.ChartModelDictionary.Add(item.Key, chartModel);
                                }
                            }
                        }
                    }
                }

                // Process ShapeTemplate elements
                if (resourceData.ResourceType == "ShapeTemplate")
                {
                    ShapeTemplate shapeTemplate = this.GetResourceByKey <ShapeTemplate>(resourceData.Key);

                    if (shapeTemplate != null)
                    {
                        WorksheetPart designerWorksheetPart = null;

                        // Get the worksheet on which the ShapeTemplate resides (Alt. look at ExcelSheetMapper.GetDesignerWorksheet...)
                        var designerSpreadsheetDocument = GetDesignerSpreadsheetDocumentByKey(shapeTemplate.Key);
                        if (designerSpreadsheetDocument != null)
                        {
                            designerWorksheetPart = designerSpreadsheetDocument.GetWorksheetPart(shapeTemplate.TemplateSheetName);
                            if (designerWorksheetPart != null)
                            {
                                ExcelModel.ShapeModel shapeModel = ExcelModel.ShapeModel.GetShapeModel(designerWorksheetPart.Worksheet, shapeTemplate.TemplateShapeName);
                                if (shapeModel != null)
                                {
                                    this.ShapeModelDictionary.Add(item.Key, shapeModel);
                                }
                            }
                        }
                    }
                }

                // Process PictureTemplate elements
                if (resourceData.ResourceType == "PictureTemplate")
                {
                    PictureTemplate pictureTemplate = this.GetResourceByKey <PictureTemplate>(resourceData.Key);

                    if (pictureTemplate != null)
                    {
                        WorksheetPart designerWorksheetPart = null;

                        // Get the worksheet on which the ShapeTemplate resides (Alt. look at ExcelSheetMapper.GetDesignerWorksheet...)
                        var designerSpreadsheetDocument = GetDesignerSpreadsheetDocumentByKey(pictureTemplate.Key);
                        if (designerSpreadsheetDocument != null)
                        {
                            designerWorksheetPart = designerSpreadsheetDocument.GetWorksheetPart(pictureTemplate.TemplateSheetName);
                            if (designerWorksheetPart != null)
                            {
                                ExcelModel.PictureModel pictureModel = ExcelModel.PictureModel.GetPictureModel(designerWorksheetPart.Worksheet, pictureTemplate.TemplatePictureName);
                                if (pictureModel != null)
                                {
                                    this.PictureModelDictionary.Add(item.Key, pictureModel);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Adds the specified key.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="resourceType">Type of the resource.</param>
        /// <param name="instance">The instance.</param>
        /// <param name="uri">The URI.</param>
        internal void Add(string key, string resourceType, IResource instance, string uri)
        {
            var rd = new ResourceData(key, resourceType, instance, uri);

            this.Add(rd);
        }