/// <summary> /// 自动播放PPT文档. /// </summary> /// <param name="filePath">PPTy文件路径.</param> /// <param name="playTime">翻页的时间间隔.【以秒为单位】</param> public void PPTAuto(string filePath, int playTime) { //防止连续打开多个PPT程序. if (this.objApp != null) { return; } objApp = new POWERPOINT.Application(); objPresSet = objApp.Presentations.Open(filePath, OFFICECORE.MsoTriState.msoCTrue, OFFICECORE.MsoTriState.msoFalse, OFFICECORE.MsoTriState.msoFalse); // 自动播放的代码(开始) int Slides = objPresSet.Slides.Count; int[] SlideIdx = new int[Slides]; for (int i = 0; i < Slides; i++) { SlideIdx[i] = i + 1; } ; objSldRng = objPresSet.Slides.Range(SlideIdx); objSST = objSldRng.SlideShowTransition; //设置翻页的时间. objSST.AdvanceOnTime = OFFICECORE.MsoTriState.msoCTrue; objSST.AdvanceTime = playTime; //翻页时的特效! objSST.EntryEffect = POWERPOINT.PpEntryEffect.ppEffectCircleOut; //Prevent Office Assistant from displaying alert messages: bAssistantOn = objApp.Assistant.On; objApp.Assistant.On = false; //Run the Slide show from slides 1 thru 3. objSSS = objPresSet.SlideShowSettings; objSSS.StartingSlide = 1; objSSS.EndingSlide = Slides; objSSS.Run(); //Wait for the slide show to end. objSSWs = objApp.SlideShowWindows; while (objSSWs.Count >= 1) { System.Threading.Thread.Sleep(playTime * 100); } this.objPresSet.Close(); this.objApp.Quit(); }
public void Open(string PPT) { if (!System.IO.File.Exists(PPT)) { return; } try { axFramerControl1.Open(PPT, true, "PowerPoint.Show", "", ""); pptDoc = (Presentation)axFramerControl1.ActiveDocument; pptApp = pptDoc.Application; pptDoc.SlideShowSettings.RangeType = PpSlideShowRangeType.ppShowNamedSlideShow; pptDoc.SlideShowSettings.ShowType = PpSlideShowType.ppShowTypeWindow; pptDoc.SlideShowSettings.LoopUntilStopped = MsoTriState.msoCTrue; int Slides = pptDoc.Slides.Count; int[] SlideIdx = new int[Slides]; for (int i = 0; i < SlideIdx.Length; i++) { SlideIdx[i] = i + 1; } pptSldRng = pptDoc.Slides.Range(SlideIdx); pptSST = pptSldRng.SlideShowTransition; pptSST.AdvanceOnTime = MsoTriState.msoCTrue; pptSST.AdvanceTime = flushSpeed; pptSST.EntryEffect = PpEntryEffect.ppEffectFade; pptDoc.Save(); SendKeys.Send("{F5}"); } catch (Exception e) { All.Class.Error.Add(e); } }
//评分核心函数 public int check_Kernel(List<OfficeElement> ls) { int points = 0, i; int curPart = -1; //当前正在分析哪一部分的考点 for (i = 0; i < ls.Count; i++) { OfficeElement oe = ls[i]; #region 具体考点对象定位 if (oe.AttribName == "Root") continue; if (oe.AttribName == "Presentations") continue; if (oe.AttribName == "Slide") { #region 幻灯片定位 try { int slideId = int.Parse(oe.AttribValue); stuSld = stuPpt.Slides[slideId]; ansSld = ansPpt.Slides[slideId]; } catch { points = 0; break; } #endregion curPart = PART_SLIDE; continue; } if (oe.AttribName == "Background") { #region 幻灯片背景定位 try { stuBg = stuSld.Background; ansBg = ansSld.Background; } catch { points = 0; break; } #endregion curPart = PART_BACKGROUND; continue; } if (oe.AttribName == "Transition") { #region 过渡动画定位 try { stuTrans = stuSld.SlideShowTransition; ansTrans = ansSld.SlideShowTransition; } catch { points = 0; break; } #endregion curPart = PART_TRANSITION; continue; } if (oe.AttribName == "Effects") { continue; } if (oe.AttribName == "Effect") { #region 幻灯片动画定位 try { int effId = int.Parse(oe.AttribValue); stuEffect = stuSld.TimeLine.MainSequence[effId]; ansEffect = ansSld.TimeLine.MainSequence[effId]; } catch { points = 0; break; } #endregion curPart = PART_EFFECT; continue; } if (oe.AttribName == "Shape") { #region Shape定位 try { int shapeId = int.Parse(oe.AttribValue); stuShape = stuSld.Shapes[shapeId]; ansShape = ansSld.Shapes[shapeId]; } catch { points = 0; break; } #endregion curPart = PART_SHAPE; continue; } if (oe.AttribName == "Location") { curPart = PART_LOCATION; continue; } if (oe.AttribName == "Picture") { #region 图片属性定位 try { stuPf = stuShape.PictureFormat; ansPf = ansShape.PictureFormat; } catch { points = 0; break; } #endregion curPart = PART_PICTURE; continue; } if (oe.AttribName == "Run") { #region 文字部分定位 try { int runId = int.Parse(oe.AttribValue); stuTr = stuShape.TextFrame.TextRange.Runs(0, 100); ansTr = ansShape.TextFrame.TextRange.Runs(0, 100); } catch { points = 0; break; } #endregion curPart = PART_TEXTRANGE; continue; } if (oe.AttribName == "WordArt") { #region 艺术字定位 try { stuTf = stuShape.TextEffect; ansTf = ansShape.TextEffect; } catch { points = 0; break; } #endregion curPart = PART_WORDART; continue; } if (oe.AttribName == "ThreeD") { #region 三维属性定位 try { stu3d = stuShape.ThreeD; ans3d = ansShape.ThreeD; } catch { points = 0; break; } #endregion curPart = PART_3D; continue; } if (oe.AttribName == "Animation") { #region 自定义动画定位 try { stuAm = stuShape.AnimationSettings; ansAm = ansShape.AnimationSettings; } catch { points = 0; break; } #endregion curPart = PART_ANIMATION; continue; } if (oe.AttribName == "ClickAction") { #region 单击动作定位 try { stuAcs = stuShape.ActionSettings[PowerPoint.PpMouseActivation.ppMouseClick]; ansAcs = ansShape.ActionSettings[PowerPoint.PpMouseActivation.ppMouseClick]; } catch { points = 0; break; } #endregion curPart = PART_ACTION; continue; } if (oe.AttribName == "MoveAction") { #region 鼠标移动动作定位 try { stuAcs = stuShape.ActionSettings[PowerPoint.PpMouseActivation.ppMouseOver]; ansAcs = ansShape.ActionSettings[PowerPoint.PpMouseActivation.ppMouseOver]; } catch { points = 0; break; } #endregion curPart = PART_ACTION; continue; } #endregion #region 幻灯片判分 if (curPart == PART_SLIDE) { switch (oe.AttribName) { case "SlideName": if (stuSld.Name == ansSld.Name) points = int.Parse(oe.AttribValue); break; case "SlideIndex": if (stuSld.SlideIndex == ansSld.SlideIndex) points = int.Parse(oe.AttribValue); break; case "Layout": if (stuSld.Layout == ansSld.Layout) points = int.Parse(oe.AttribValue); break; } continue; } #endregion #region 幻灯片背景判分 if (curPart == PART_BACKGROUND) { switch (oe.AttribName) { case "Fill": if (stuBg.Fill.Type.Equals(ansBg.Fill.Type)) points = int.Parse(oe.AttribValue); break; case "GradientType": if (stuBg.Fill.PresetGradientType == ansBg.Fill.PresetGradientType) points = int.Parse(oe.AttribValue); break; case "GradientStyle": if (stuBg.Fill.GradientStyle == ansBg.Fill.GradientStyle) points = int.Parse(oe.AttribValue); break; } continue; } #endregion #region 幻灯片过渡动画判分 if (curPart == PART_TRANSITION) { switch (oe.AttribName) { case "AdvanceOnClick": if (stuTrans.AdvanceOnClick.Equals(ansTrans.AdvanceOnClick)) points = int.Parse(oe.AttribValue); break; case "AdvanceOnTime": if (stuTrans.AdvanceOnTime.Equals(ansTrans.AdvanceOnTime)) points = int.Parse(oe.AttribValue); break; case "AdvanceTime": if (stuTrans.AdvanceTime == ansTrans.AdvanceTime) points = int.Parse(oe.AttribValue); break; case "EntryEffect": if (stuTrans.EntryEffect.Equals(ansTrans.EntryEffect)) points = int.Parse(oe.AttribValue); break; case "Speed": if (stuTrans.Speed.Equals(ansTrans.Speed)) points = int.Parse(oe.AttribValue); break; } continue; } #endregion #region 幻灯片动画判分 if (curPart == PART_EFFECT) { switch (oe.AttribName) { case "DisplayName": if (stuEffect.DisplayName == ansEffect.DisplayName) points = int.Parse(oe.AttribValue); break; case "EffectType": if (stuEffect.EffectType.Equals(ansEffect.EffectType)) points = int.Parse(oe.AttribValue); break; case "Exit": if (stuEffect.Exit.Equals(ansEffect.Exit)) points = int.Parse(oe.AttribValue); break; case "Index": if (stuEffect.Index == ansEffect.Index) points = int.Parse(oe.AttribValue); break; case "ShapeName": if (stuEffect.Shape.Name == ansEffect.Shape.Name) points = int.Parse(oe.AttribValue); break; case "Duration": if (stuEffect.Timing.Duration == ansEffect.Timing.Duration) points = int.Parse(oe.AttribValue); break; case "Paragraph": try { if (stuEffect.Paragraph == ansEffect.Paragraph) points = int.Parse(oe.AttribValue); } catch { points = 0; } break; case "TextRangeStart": try { if (stuEffect.TextRangeStart == ansEffect.TextRangeStart) points = int.Parse(oe.AttribValue); } catch { points = 0; } break; case "TextRangeLength": try { if (stuEffect.TextRangeLength == ansEffect.TextRangeLength) points = int.Parse(oe.AttribValue); } catch { points = 0; } break; } continue; } #endregion #region 幻灯片对象判分 if (curPart == PART_SHAPE) { continue; } #endregion #region 对象类型、定位判分 if (curPart == PART_LOCATION) { switch (oe.AttribName) { case "ShapeName": if (stuShape.Name == ansShape.Name) points = int.Parse(oe.AttribValue); break; case "Type": if (stuShape.Type == ansShape.Type) points = int.Parse(oe.AttribValue); break; case "Top": if (stuShape.Top == ansShape.Top) points = int.Parse(oe.AttribValue); break; case "Left": if (stuShape.Left == ansShape.Left) points = int.Parse(oe.AttribValue); break; case "Height": if (stuShape.Height == ansShape.Height) points = int.Parse(oe.AttribValue); break; case "Width": if (stuShape.Width == ansShape.Width) points = int.Parse(oe.AttribValue); break; } continue; } #endregion #region 图片属性判分 if (curPart == PART_PICTURE) { switch (oe.AttribName) { case "CropLeft": if (stuPf.CropLeft == ansPf.CropLeft) points = int.Parse(oe.AttribValue); break; case "CropTop": if (stuPf.CropTop == ansPf.CropTop) points = int.Parse(oe.AttribValue); break; case "CropRight": if (stuPf.CropRight == ansPf.CropRight) points = int.Parse(oe.AttribValue); break; case "CropBottom": if (stuPf.CropBottom == ansPf.CropBottom) points = int.Parse(oe.AttribValue); break; } continue; } #endregion #region 文本属性判分 if (curPart == PART_TEXTRANGE) { switch (oe.AttribName) { case "Text": if (stuTr.Text == ansTr.Text) points = int.Parse(oe.AttribValue); break; case "Bold": if (stuTr.Font.Bold == ansTr.Font.Bold) points = int.Parse(oe.AttribValue); break; case "Italic": if (stuTr.Font.Italic == ansTr.Font.Italic) points = int.Parse(oe.AttribValue); break; case "Underline": if (stuTr.Font.Underline == ansTr.Font.Underline) points = int.Parse(oe.AttribValue); break; case "FontName": if (stuTr.Font.Name == ansTr.Font.Name) points = int.Parse(oe.AttribValue); break; case "FontSize": if (stuTr.Font.Size == ansTr.Font.Size) points = int.Parse(oe.AttribValue); break; case "Shadow": if (stuTr.Font.Shadow == ansTr.Font.Shadow) points = int.Parse(oe.AttribValue); break; case "Superscript": if (stuTr.Font.Superscript == ansTr.Font.Superscript) points = int.Parse(oe.AttribValue); break; case "Subscript": if (stuTr.Font.Subscript == ansTr.Font.Subscript) points = int.Parse(oe.AttribValue); break; case "ForeColor": if (stuTr.Font.Color.RGB == ansTr.Font.Color.RGB) points = int.Parse(oe.AttribValue); break; } continue; } #endregion #region 艺术字属性判分 if (curPart == PART_WORDART) { switch (oe.AttribName) { case "Text": if (stuTf.Text == ansTf.Text) points = int.Parse(oe.AttribValue); break; case "Bold": if (stuTf.FontBold == ansTf.FontBold) points = int.Parse(oe.AttribValue); break; case "Italic": if (stuTf.FontItalic == ansTf.FontItalic) points = int.Parse(oe.AttribValue); break; case "FontName": if (stuTf.FontName == ansTf.FontName) points = int.Parse(oe.AttribValue); break; case "FontSize": if (stuTf.FontSize == ansTf.FontSize) points = int.Parse(oe.AttribValue); break; case "Alignment": if (stuTf.Alignment.ToString() == ansTf.Alignment.ToString()) points = int.Parse(oe.AttribValue); break; case "PresetShape": if (stuTf.PresetShape.ToString() == ansTf.PresetShape.ToString()) points = int.Parse(oe.AttribValue); break; case "RotatedChars": if (stuTf.RotatedChars.ToString() == ansTf.RotatedChars.ToString()) points = int.Parse(oe.AttribValue); break; case "Tracking": if (stuTf.Tracking.ToString() == ansTf.Tracking.ToString()) points = int.Parse(oe.AttribValue); break; } continue; } #endregion #region 三维属性判分 if (curPart == PART_3D) { switch (oe.AttribName) { case "ThreeDFormat": if (stu3d.PresetThreeDFormat == ans3d.PresetThreeDFormat) points = int.Parse(oe.AttribValue); break; case "LightingDirection": if (stu3d.PresetLightingDirection == ans3d.PresetLightingDirection) points = int.Parse(oe.AttribValue); break; case "LightingSoftness": if (stu3d.PresetLightingSoftness == ans3d.PresetLightingSoftness) points = int.Parse(oe.AttribValue); break; case "Material": if (stu3d.PresetMaterial == ans3d.PresetMaterial) points = int.Parse(oe.AttribValue); break; case "Depth": if (stu3d.Depth == ans3d.Depth) points = int.Parse(oe.AttribValue); break; case "ExtrusionDirection": if (stu3d.PresetExtrusionDirection == ans3d.PresetExtrusionDirection) points = int.Parse(oe.AttribValue); break; } continue; } #endregion #region 自定义动画判分 if (curPart == PART_ANIMATION) { switch (oe.AttribName) { case "AnimationOrder": if (stuAm.AnimationOrder == ansAm.AnimationOrder) points = int.Parse(oe.AttribValue); break; case "EntryEffect": if (stuAm.EntryEffect == ansAm.EntryEffect) points = int.Parse(oe.AttribValue); break; case "AdvanceMode": if (stuAm.AdvanceMode == ansAm.AdvanceMode) points = int.Parse(oe.AttribValue); break; case "AdvanceTime": if (stuAm.AdvanceTime == ansAm.AdvanceTime) points = int.Parse(oe.AttribValue); break; } continue; } #endregion #region 对象动作判分 if (curPart == PART_ACTION) { switch (oe.AttribName) { case "Action": if (stuAcs.Action == ansAcs.Action) points = int.Parse(oe.AttribValue); break; case "HyperlinkAddr": if (stuAcs.Hyperlink.Address == ansAcs.Hyperlink.Address) points = int.Parse(oe.AttribValue); break; case "HyperlinkSubAddr": if (stuAcs.Hyperlink.SubAddress == ansAcs.Hyperlink.SubAddress) points = int.Parse(oe.AttribValue); break; } continue; } #endregion } return points; }
private void btCameraSelectata_Click(object sender, EventArgs e) { if (cmbDisponibile.Text == "SINGLE") { Hotel = new PP.Application(); pres = Hotel.Presentations.Add(); int nrs = pres.Slides.Count; PP.CustomLayout cl = pres.SlideMaster.CustomLayouts[PP.PpSlideLayout.ppLayoutTitle]; slide = pres.Slides.AddSlide(nrs + 1, cl); slide.Shapes.Title.TextFrame.TextRange.Text = "CAMERA SINGLE"; slide.Shapes[2].TextFrame.TextRange.Text = "Camerele Single ofera oaspetilor o atmosfera calda si linistitoare care imbina perfect relaxarea cu utilul. Camerele single sunt cu vedere spre curtea interioara si asigura liniste deplina atat pe timp de zi cat si pe timp de noapte." + "Oaspetii se pot bucura de Internet wireless, televiziune prin cablu si control individual al climei."; slide.Shapes.Title.TextFrame.TextRange.Font.Color.RGB = Color.White.ToArgb(); slide.Shapes[2].TextFrame.TextRange.Font.Color.RGB = Color.White.ToArgb(); slide.Shapes.Title.TextFrame.TextRange.Font.Bold = Office.MsoTriState.msoCTrue; slide.Shapes[2].TextFrame.TextRange.Font.Bold = Office.MsoTriState.msoCTrue; string cale = @"C:\Users\Gabriel Birzu\OneDrive\Desktop\Proiect IPLA\Poze\single1.jpg"; string cale2 = @"C:\Users\Gabriel Birzu\OneDrive\Desktop\Proiect IPLA\Poze\single2.jpg"; string cale3 = @"C:\Users\Gabriel Birzu\OneDrive\Desktop\Proiect IPLA\Poze\single3.jpg"; float lat = slide.CustomLayout.Width; float inalt = slide.CustomLayout.Height; PP.Shape shape = slide.Shapes.AddPicture(cale, Office.MsoTriState.msoCTrue, Office.MsoTriState.msoFalse, 0, 0, lat - 0, inalt - 0); slide.Shapes[2].ZOrder(Office.MsoZOrderCmd.msoBringToFront); slide.Shapes.Title.ZOrder(Office.MsoZOrderCmd.msoBringToFront); slide = pres.Slides.AddSlide(nrs + 2, cl); PP.Shape shape2 = slide.Shapes.AddPicture(cale2, Office.MsoTriState.msoCTrue, Office.MsoTriState.msoFalse, 0, 0, lat - 0, inalt - 0); slide = pres.Slides.AddSlide(nrs + 3, cl); PP.Shape shape3 = slide.Shapes.AddPicture(cale3, Office.MsoTriState.msoCTrue, Office.MsoTriState.msoFalse, 0, 0, lat - 0, inalt - 0); } if (cmbDisponibile.Text == "DOUBLE") { Hotel = new PP.Application(); pres = Hotel.Presentations.Add(); int nrs = pres.Slides.Count; PP.CustomLayout cl = pres.SlideMaster.CustomLayouts[PP.PpSlideLayout.ppLayoutTitle]; slide = pres.Slides.AddSlide(nrs + 1, cl); slide.Shapes.Title.TextFrame.TextRange.Text = "CAMERA DOUBLE"; slide.Shapes[2].TextFrame.TextRange.Text = "Camerele Double oferta oaspetilor nostri o atmosfera calda si linistitoare care imbina perfect relaxarea cu utilul. Camerele double au vedere spre cladirea Cercului Militar si Calea Victoriei asigurand o panorama incontestabila asupra arhitecturii de altadata. Oaspetii se pot bucura de Internet wireless, televiziune prin cablu si control individual al climei"; slide.Shapes.Title.TextFrame.TextRange.Font.Color.RGB = Color.White.ToArgb(); slide.Shapes[2].TextFrame.TextRange.Font.Color.RGB = Color.White.ToArgb(); slide.Shapes.Title.TextFrame.TextRange.Font.Bold = Office.MsoTriState.msoCTrue; slide.Shapes[2].TextFrame.TextRange.Font.Bold = Office.MsoTriState.msoCTrue; string cale = @"C:\Users\Gabriel Birzu\OneDrive\Desktop\Proiect IPLA\Poze\double1.jpg"; string cale2 = @"C:\Users\Gabriel Birzu\OneDrive\Desktop\Proiect IPLA\Poze\double2.jpg"; string cale3 = @"C:\Users\Gabriel Birzu\OneDrive\Desktop\Proiect IPLA\Poze\double3.jpg"; float lat = slide.CustomLayout.Width; float inalt = slide.CustomLayout.Height; PP.Shape shape = slide.Shapes.AddPicture(cale, Office.MsoTriState.msoCTrue, Office.MsoTriState.msoFalse, 0, 0, lat - 0, inalt - 0); slide.Shapes[2].ZOrder(Office.MsoZOrderCmd.msoBringToFront); slide.Shapes.Title.ZOrder(Office.MsoZOrderCmd.msoBringToFront); slide = pres.Slides.AddSlide(nrs + 2, cl); PP.Shape shape2 = slide.Shapes.AddPicture(cale2, Office.MsoTriState.msoCTrue, Office.MsoTriState.msoFalse, 0, 0, lat - 0, inalt - 0); slide = pres.Slides.AddSlide(nrs + 3, cl); PP.Shape shape3 = slide.Shapes.AddPicture(cale3, Office.MsoTriState.msoCTrue, Office.MsoTriState.msoFalse, 0, 0, lat - 0, inalt - 0); } if (cmbDisponibile.Text == "APARTAMENT") { Hotel = new PP.Application(); pres = Hotel.Presentations.Add(); int nrs = pres.Slides.Count; PP.CustomLayout cl = pres.SlideMaster.CustomLayouts[PP.PpSlideLayout.ppLayoutTitle]; slide = pres.Slides.AddSlide(nrs + 1, cl); slide.Shapes.Title.TextFrame.TextRange.Text = "APARTAMENT"; slide.Shapes[2].TextFrame.TextRange.Text = "Apartamentele ofera oaspetilor nostri o atmosfera calda si linistitoare care imbina perfect relaxarea cu utilul. Apartamentele au vedere spre cladirea Cercului Militar si Calea Victoriei, asigurand o panorama incontestabila asupra arhitecturii de altadata. Oaspetii se pot bucura de Internet wireless, televiziune prin cablu si control individual al climei."; slide.Shapes.Title.TextFrame.TextRange.Font.Color.RGB = Color.White.ToArgb(); slide.Shapes[2].TextFrame.TextRange.Font.Color.RGB = Color.White.ToArgb(); slide.Shapes.Title.TextFrame.TextRange.Font.Bold = Office.MsoTriState.msoCTrue; slide.Shapes[2].TextFrame.TextRange.Font.Bold = Office.MsoTriState.msoCTrue; string cale = @"C:\Users\Gabriel Birzu\OneDrive\Desktop\Proiect IPLA\Poze\ap1.jpg"; string cale2 = @"C:\Users\Gabriel Birzu\OneDrive\Desktop\Proiect IPLA\Poze\ap2.jpg"; string cale3 = @"C:\Users\Gabriel Birzu\OneDrive\Desktop\Proiect IPLA\Poze\ap3.jpg"; float lat = slide.CustomLayout.Width; float inalt = slide.CustomLayout.Height; PP.Shape shape = slide.Shapes.AddPicture(cale, Office.MsoTriState.msoCTrue, Office.MsoTriState.msoFalse, 0, 0, lat - 0, inalt - 0); slide.Shapes[2].ZOrder(Office.MsoZOrderCmd.msoBringToFront); slide.Shapes.Title.ZOrder(Office.MsoZOrderCmd.msoBringToFront); slide = pres.Slides.AddSlide(nrs + 2, cl); PP.Shape shape2 = slide.Shapes.AddPicture(cale2, Office.MsoTriState.msoCTrue, Office.MsoTriState.msoFalse, 0, 0, lat - 0, inalt - 0); slide = pres.Slides.AddSlide(nrs + 3, cl); PP.Shape shape3 = slide.Shapes.AddPicture(cale3, Office.MsoTriState.msoCTrue, Office.MsoTriState.msoFalse, 0, 0, lat - 0, inalt - 0); } PP.SlideRange ssr = pres.Slides.Range(); PP.SlideShowTransition sst = ssr.SlideShowTransition; sst.AdvanceOnTime = Office.MsoTriState.msoTrue; sst.AdvanceTime = 3; sst.EntryEffect = PP.PpEntryEffect.ppEffectRevealSmoothRight; PP.SlideShowSettings ssp = pres.SlideShowSettings; ssp.StartingSlide = 1; ssp.EndingSlide = pres.Slides.Count; ssp.Run(); }
/// <summary> /// 自动播放PPT文档. /// </summary> /// <param name="filePath">PPT文件路径.</param> /// <param name="playTime">翻页的时间间隔.【以秒为单位】</param> /// <param name="timeout">超时限制【以秒为单位】</param> public void PPTAuto(object presSet, int playTime, int timeout) { iSlideShowTime = playTime; objPresSet = (POWERPOINT.Presentation)presSet; if (timeout > 0 && objPresSet.Slides.Count * playTime > timeout) { objApp_SlideShowNextSlide(null); return; } objApp = objPresSet.Application; iSlideIndex = 0; try { // 自动播放的代码(开始) int Slides = objPresSet.Slides.Count; int[] SlideIdx = new int[Slides]; for (int i = 0; i < Slides; i++) { SlideIdx[i] = i + 1; }; objSldRng = objPresSet.Slides.Range(SlideIdx); objSST = objSldRng.SlideShowTransition; //关闭助手显示 objApp.Assistant.On = false; objApp.Assistant.Visible = false; //设置翻页的时间. objSST.AdvanceOnTime = OFFICECORE.MsoTriState.msoCTrue; objSST.AdvanceTime = playTime; //翻页时的特效! objSST.EntryEffect = POWERPOINT.PpEntryEffect.ppEffectCircleOut; //Run the Slide show from slides 1 thru 3. objSSS = objPresSet.SlideShowSettings; objSSS.StartingSlide = 1; objSSS.EndingSlide = Slides; objApp.SlideShowNextSlide += new POWERPOINT.EApplication_SlideShowNextSlideEventHandler(objApp_SlideShowNextSlide); hook.Hook_Clear(); hook.Hook_Start(); objSSS.Run(); } catch { hook.Hook_Clear(); } }
public static void IncludeOthers(string path) { //Build Slide #2: //Add text to the slide title, format the text. Also add a chart to the //slide and change the chart type to a 3D pie chart. objSlide = objSlides.Add(objSlides.Count + 1, PowerPoint.PpSlideLayout.ppLayoutTitleOnly); objTextRng = objSlide.Shapes[1].TextFrame.TextRange; objTextRng.Text = "My Chart"; objTextRng.Font.Name = "Comic Sans MS"; objTextRng.Font.Size = 48; objChart = (Graph.Chart)objSlide.Shapes.AddOLEObject(150, 150, 480, 320, "MSGraph.Chart.8", "", MsoTriState.msoFalse, "", 0, "", MsoTriState.msoFalse).OLEFormat.Object; objChart.ChartType = Graph.XlChartType.xl3DPie; objChart.Legend.Position = Graph.XlLegendPosition.xlLegendPositionBottom; objChart.HasTitle = true; objChart.ChartTitle.Text = "Here it is..."; //Build Slide #3: //Change the background color of this slide only. Add a text effect to the slide //and apply various color schemes and shadows to the text effect. objSlide = objSlides.Add(objSlides.Count + 1, PowerPoint.PpSlideLayout.ppLayoutBlank); objSlide.FollowMasterBackground = MsoTriState.msoFalse; objShapes = objSlide.Shapes; objShape = objShapes.AddTextEffect(MsoPresetTextEffect.msoTextEffect27, "The End", "Impact", 96, MsoTriState.msoFalse, MsoTriState.msoFalse, 230, 200); //Save the presentation to disk objPres.SaveAs(path, PowerPoint.PpSaveAsFileType.ppSaveAsPresentation, Microsoft.Office.Core.MsoTriState.msoFalse); //Modify the slide show transition settings for all 3 slides in //the presentation. int[] SlideIdx = new int[3]; for (int k = 0; k < 3; k++) SlideIdx[k] = k + 1; objSldRng = objSlides.Range(SlideIdx); objSST = objSldRng.SlideShowTransition; objSST.AdvanceOnTime = MsoTriState.msoTrue; objSST.AdvanceTime = 3; objSST.EntryEffect = PowerPoint.PpEntryEffect.ppEffectBoxOut; //Prevent Office Assistant from displaying alert messages: // bAssistantOn = objApp.Assistant.On; // objApp.Assistant.On = false; //Run the Slide show from slides 1 thru 3. objSSS = objPres.SlideShowSettings; objSSS.StartingSlide = 1; objSSS.EndingSlide = 3; objSSS.Run(); //Wait for the slide show to end. objSSWs = objApp.SlideShowWindows; while (objSSWs.Count >= 1) System.Threading.Thread.Sleep(100); ////Reenable Office Assisant, if it was on: //if (bAssistantOn) //{ // objApp.Assistant.On = true; // objApp.Assistant.Visible = false; //} //Close the presentation without saving changes and quit PowerPoint. // objPres.Close(); // objApp.Quit(); }