当前位置: 首页>>代码示例>>C#>>正文


C# Model.AddSlideContent方法代码示例

本文整理汇总了C#中System.ComponentModel.Model.AddSlideContent方法的典型用法代码示例。如果您正苦于以下问题:C# Model.AddSlideContent方法的具体用法?C# Model.AddSlideContent怎么用?C# Model.AddSlideContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.ComponentModel.Model的用法示例。


在下文中一共展示了Model.AddSlideContent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessLayer

        /// <summary>
        /// 
        /// </summary>
        /// <param name="tfc"></param>
        /// <param name="shapes"></param>
        /// <param name="range"></param>
        /// <param name="deck"></param>
        /// <param name="slide"></param>
        /// <param name="disposition"></param>
        /// <param name="emfHeight"></param>
        /// <param name="startHeight">The starting height to place this sheet at</param>
        private static void ProcessLayer( List<TaggedShape> layer, TempFileCollection tfc, PowerPoint.Shapes shapes, Model.Presentation.DeckModel deck, 
            Model.Presentation.SlideModel slide, float emfWidthRatio, float emfHeightRatio, int startHeight)
        {
            if (layer.Count < 1)
                return;

            //Create the image
            int[] range = PPTDeckIO.BuildIntRange(layer);
            PowerPoint.ShapeRange sr = shapes.Range(range);

            PowerPoint.PpShapeFormat format;
            string fileExt = "";
            bool bitmapMode = layer[0].isImage;

            if (bitmapMode) {
                format = PowerPoint.PpShapeFormat.ppShapeFormatPNG;
                fileExt = "png";
            }
            else {
                format = PowerPoint.PpShapeFormat.ppShapeFormatEMF;
                fileExt = "emf";
            }

            //Generate a new filename
            string dirpath = tfc.BasePath;
            string filename = PPTDeckIO.GenerateFilename();
            filename = dirpath + "\\" + filename + "." + fileExt;
            while (File.Exists(filename)) {
                filename = PPTDeckIO.GenerateFilename();
                filename = dirpath + "\\" + filename + "." + fileExt;
            }

            sr.Export(filename, format, 0, 0,
                PowerPoint.PpExportMode.ppRelativeToSlide);

            if (bitmapMode) {
                // Starting with Office 2013, bitmaps may not be exported in the correct size.
                double version;
                if (!double.TryParse(((PowerPoint.Application)shapes.Application).Version, out version)) {
                    version = 0.0;
                }
                if (version >= 15.0) {
                    ScaleShapeImage(sr, filename);
                }
            }

            tfc.AddFile(filename, false);
            //Compute the MD5 of the BG
            FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
            MD5 md5Provider = new MD5CryptoServiceProvider();
            byte[] md5 = md5Provider.ComputeHash(fs);
            fs.Seek(0, SeekOrigin.Begin);
            Image image = Image.FromStream(fs);

            if (bitmapMode)
                image = DisassociateBitmap(image);

            fs.Close();
            //Calculate the geometry
            int xCoord = 0;
            int yCoord = 0;
            int width = 0;
            int height = 0;
            PPTDeckIO.CalculateGeometry( image, shapes, range, emfWidthRatio, emfHeightRatio, ref xCoord, ref yCoord, ref width, ref height );
            //Create the ImageSheet
            ImageSheetModel sheet = new ImageSheetModel(deck, Guid.NewGuid(), layer[0].disp,
                new Rectangle(xCoord, yCoord, width, height), (ByteArray)md5, startHeight);
            //Add the ImageSheet to the Slide
            slide.ContentSheets.Add(sheet);
            //Add the Image+MD5 to the deck
            deck.AddSlideContent((ByteArray)md5, image);
        }
开发者ID:ClassroomPresenter,项目名称:CP3,代码行数:83,代码来源:PPTDeckIO.cs


注:本文中的System.ComponentModel.Model.AddSlideContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。