Beispiel #1
0
 //此为Application对象的PresentationNewSlide事件
 //功能:当用户将新幻灯片添加到活动演示文稿时,此事件处理程序会将文本框添加到新幻灯片的顶部,然后向文本框中添加一些文本。
 void Application_PresentationNewSlide(PowerPoint.Slide Sld)
 {
     //这里的Application表示 PowerPoint 的当前实例。
     //这里的参数Sld,表示新幻灯片的Slide对象。
     PowerPoint.Shape textBox = Sld.Shapes.AddTextbox(Office.MsoTextOrientation.msoTextOrientationHorizontal, 0, 0, 500, 50);
     textBox.TextFrame.TextRange.InsertAfter("This Text Was Added By Using Code!");
 }
Beispiel #2
0
 private void button_Connect_Click(object sender, EventArgs e)
 {
     try
     {
         pptApplication = Marshal.GetActiveObject("PowerPoint.Application") as PPT.Application;
         presentation   = pptApplication.ActivePresentation;
         slides         = presentation.Slides;
         slidescount    = slides.Count;
         try
         {
             // Get selected slide object in normal view
             slide = slides[pptApplication.ActiveWindow.Selection.SlideRange.SlideNumber];
         }
         catch
         {
             // Get selected slide object in reading view
             slide = pptApplication.SlideShowWindows[1].View.Slide;
         }
         powercon               = true;
         button_Connect.Text    = "Powerpoint Connected";
         button_Connect.Enabled = false;
     }
     catch
     {
         MetroFramework.MetroMessageBox.Show(this, "Please check PowerPoint is running.", "Maestro", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #3
0
        /// <summary>
        /// 文字替换
        /// </summary>
        public void ReplaceText(KeyValuePair <string, string> kv)
        {
            string OldText = string.Empty;
            string NewText = string.Empty;

            OldText = kv.Key;
            NewText = kv.Value;

            int num = PageNum();

            for (int j = 1; j <= num; j++)
            {
                POWERPOINT.Slide slide = objPresSet.Slides[j];
                for (int i = 1; i <= slide.Shapes.Count; i++)
                {
                    try
                    {
                        POWERPOINT.Shape shape = slide.Shapes[i];
                        if (shape.TextFrame != null)
                        {
                            POWERPOINT.TextFrame textFrame = shape.TextFrame;
                            string oldText = textFrame.TextRange.Text;
                            string newText = textFrame.TextRange.Text.Replace(OldText, NewText);
                            if (textFrame.TextRange != null && !string.IsNullOrEmpty(oldText))
                            {
                                textFrame.TextRange.Replace(oldText, newText);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
        }
Beispiel #4
0
        public void CreateSlide(string slideTitle, string slideBody)
        {
            if (slideBody.Contains("\r\n\r\n") || String.IsNullOrEmpty(slideBody) || slideBody == "\r\n")
            {
                return;
            }
            float slideWidth       = m_pptPres.PageSetup.SlideWidth;
            float lyricsShapeWidth = 900;
            float lyricsShapeLeft  = slideWidth * 0.5f - lyricsShapeWidth * 0.5f;
            int   textBoxHeight    = 0;

            PowerPoint.Slide pptSlide = m_pptSlides.Add(m_pptSlides.Count + 1,
                                                        PowerPoint.PpSlideLayout.ppLayoutBlank);
            PowerPoint.Shapes pptShapes = pptSlide.Shapes;

            pptShapes.AddTextbox(Office.MsoTextOrientation.msoTextOrientationHorizontal,
                                 /*left*/ 50, /*top*/ 50, /*width*/ 700, /*height*/ textBoxHeight);

            PowerPoint.Shape titleTextbox = pptShapes[1];
            WriteToTextbox(slideTitle, titleTextbox, 50);

            pptShapes.AddTextbox(Office.MsoTextOrientation.msoTextOrientationHorizontal,
                                 lyricsShapeLeft, 150, lyricsShapeWidth, textBoxHeight);

            PowerPoint.Shape lyricsTextbox = pptShapes[2];
            WriteToLyricsTextbox(slideBody, lyricsTextbox, 35);
        }
Beispiel #5
0
        private void AddAName(PowerPoint.Slide ppSlide, string name, int idx, int nameCount)
        {
            float  left   = 0;
            float  top    = 0;
            float  radius = SlideHeightCentre;
            float  offset = SlideHeightCentre / SlideWidthCentre;
            double t      = 2 * Math.PI * idx / nameCount;

            left = (float)(SlideWidthCentre + radius * Math.Cos(t) * 1.5);
            top  = (float)(SlideHeightCentre + radius * Math.Sin(t) * 0.7);

            PowerPoint.Shape tempShape = ppSlide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, left, top, 120, 60);
            tempShape.TextFrame.TextRange.Text = name;

            tempShape.AnimationSettings.Animate = MsoTriState.msoTrue;
            if (idx == 1)
            {
                tempShape.AnimationSettings.AdvanceMode = PowerPoint.PpAdvanceMode.ppAdvanceOnClick;
            }
            else
            {
                tempShape.AnimationSettings.AdvanceMode = PowerPoint.PpAdvanceMode.ppAdvanceOnTime;
            }
            tempShape.AnimationSettings.AfterEffect = PowerPoint.PpAfterEffect.ppAfterEffectHide;
        }
Beispiel #6
0
 private void ButtonDown_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         slideIndex = slide.SlideIndex + 1;
     }
     catch
     {
         WdMessageBox.Display("Error", "PPT已关闭", "真是不幸");
         App.Current.Shutdown();
     }
     if (slideIndex > slidesCount)
     {
         WdMessageBox.Display("Info", "已经到了最后一页", "", "", "哦");
         slideIndex = slidesCount;
     }
     else
     {
         try
         {
             slide = slides[slideIndex];
             slides[slideIndex].Select();
         }
         catch
         {
             // 在阅读模式下使用下面的方式来切换到下一张幻灯片
             pptApplication.SlideShowWindows[1].View.Next();
             slide = pptApplication.SlideShowWindows[1].View.Slide;
         }
     }
     UpdateSlideIndex();
 }
 /// <summary>
 /// For `preview`
 /// </summary>
 /// <param name="slide">the temp slide to produce preview image</param>
 /// <param name="contentSlide">the slide that contains content</param>
 /// <param name="slideWidth"></param>
 /// <param name="slideHeight"></param>
 /// <param name="source"></param>
 private EffectsDesigner(PowerPoint.Slide slide, PowerPoint.Slide contentSlide, 
     float slideWidth, float slideHeight, ImageItem source)
     : base(slide)
 {
     ContentSlide = contentSlide;
     Setup(slideWidth, slideHeight, source);
 }
Beispiel #8
0
        void speech_SpeakCompleted(object sender, SpeakCompletedEventArgs e)
        {
            if (FileType == "mp3")
            {
                speech.Dispose();
                speech = new SpeechSynthesizer();
                WavToMp3(name, name0 + ".mp3");
                File.Delete(name);
                name = name0 + ".mp3";
            }

            if (!IsToPPT.Checked)
            {
                System.Diagnostics.Process.Start("Explorer.exe", name);
            }
            else
            {
                PowerPoint.Slide cslide = app.ActiveWindow.View.Slide;
                PowerPoint.Shape audio  = cslide.Shapes.AddMediaObject2(name, Office.MsoTriState.msoFalse, Office.MsoTriState.msoTrue, 0, 0, 50, 50);
                audio.AnimationSettings.PlaySettings.HideWhileNotPlaying = Office.MsoTriState.msoTrue;
                audio.AnimationSettings.Animate        = Office.MsoTriState.msoTrue;
                audio.AnimationSettings.AnimationOrder = 1;
                audio.AnimationSettings.AdvanceMode    = PowerPoint.PpAdvanceMode.ppAdvanceOnTime;
            }
        }
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            //Create a presentation
            PowerPoint.Presentation pres = Globals.ThisAddIn.Application
                                           .Presentations.Add(Microsoft.Office.Core.MsoTriState.msoFalse);

            //Get the blank slide layout
            PowerPoint.CustomLayout layout = pres.SlideMaster.
                                             CustomLayouts[7];

            //Add a blank slide
            PowerPoint.Slide sld = pres.Slides.AddSlide(1, layout);

            //Add a text
            PowerPoint.Shape shp = sld.Shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal, 150, 100, 400, 100);

            //Set a text
            PowerPoint.TextRange txtRange = shp.TextFrame.TextRange;
            txtRange.Text      = "Text added dynamically";
            txtRange.Font.Name = "Arial";
            txtRange.Font.Bold = Microsoft.Office.Core.MsoTriState.msoTrue;
            txtRange.Font.Size = 32;

            //Write the output to disk
            pres.SaveAs("outVSTOAddingText.ppt",
                        PowerPoint.PpSaveAsFileType.ppSaveAsPresentation,
                        Microsoft.Office.Core.MsoTriState.msoFalse);
        }
Beispiel #10
0
        /// <summary>
        /// Seek for for notes in current PowerPoint slide.
        /// </summary>
        /// <returns>String with notes.</returns>
        static private string GetNotesFromCurrentSlide()
        {
            string slideNotes = string.Empty;

            PowerPoint.Slide slide = Globals.ThisAddIn.Application.ActiveWindow.View.Slide;

            if (null != slide)
            {
                if (slide.HasNotesPage == Office.MsoTriState.msoTrue)
                {
                    PowerPoint.SlideRange notesPages = slide.NotesPage;
                    foreach (PowerPoint.Shape shape in notesPages.Shapes)
                    {
                        if (shape.Type == Office.MsoShapeType.msoPlaceholder)
                        {
                            if (shape.PlaceholderFormat.Type == PowerPoint.PpPlaceholderType.ppPlaceholderBody)
                            {
                                slideNotes = shape.TextFrame.TextRange.Text;
                                break;
                            }
                        }
                    }
                }
            }

            return(slideNotes);
        }
Beispiel #11
0
        /// <summary>
        /// Add or replace audio object in current slide with title "PptPollyVoice".
        /// </summary>
        /// <param name="text">Text to become speech.</param>
        /// <param name="voice">Voice name.</param>
        static private void SetPollyAudioForCurrentSlide(string text, string voice)
        {
            PowerPoint.Slide slide = Globals.ThisAddIn.Application.ActiveWindow.View.Slide;

            if (null != slide)
            {
                // Seek for and remove previous audio
                foreach (PowerPoint.Shape shape in slide.Shapes)
                {
                    string title = shape.Title;
                    if (string.Compare(title, "PptPollyVoice", StringComparison.Ordinal) == 0)
                    {
                        shape.Delete();
                        break;
                    }
                }
            }

            string speechFilename = SpeechSynthesizer.GetSpeech(text, voice);

            PowerPoint.Shape audioShape = slide.Shapes.AddMediaObject2(speechFilename);
            audioShape.Title = "PptPollyVoice";
            audioShape.AnimationSettings.PlaySettings.HideWhileNotPlaying = Office.MsoTriState.msoTrue;
            audioShape.AnimationSettings.PlaySettings.PlayOnEntry         = Office.MsoTriState.msoTrue;
        }
Beispiel #12
0
        public void MakeURL(Office.IRibbonControl control)
        {
            PowerPoint.Application  appl            = Globals.ThisAddIn.Application;
            PowerPoint.Presentation thePresentation = appl.ActivePresentation;
            PowerPoint.Slide        theSlide        = appl.ActiveWindow.View.Slide;
            PowerPoint.Selection    selection       = appl.ActiveWindow.Selection;
            String urlstring = UrlHandler.Program.PREFIX + thePresentation.FullName;

            urlstring += "#" + theSlide.SlideIndex;
            if (control.Id.StartsWith("MakeURLShape") ||
                control.Id.StartsWith("MakeURLTextEdit") ||
                control.Id.StartsWith("MakeURLObjectsGroup"))
            {
                urlstring += "!";
                String[] names = new String[selection.ShapeRange.Count];
                for (int i = 0; i < selection.ShapeRange.Count; i++)
                {
                    urlstring += selection.ShapeRange[1 + i].Name + ",";
                }
                urlstring = urlstring.Substring(0, urlstring.Length - 1); // trim trailing [!,]
            }
            // paste text to clipboard
            DataObject data = new DataObject();

            data.SetData(DataFormats.Text, urlstring);
            // paste html to clipboard
            string cf_html = HTMLClipboardFormat(urlstring);

            byte[] cf_html_bytes = Encoding.UTF8.GetBytes(cf_html);
            data.SetData(DataFormats.Html, new MemoryStream(cf_html_bytes));
            Clipboard.SetDataObject(data, true);
        }
Beispiel #13
0
 private void button2_Click(object sender, EventArgs e)
 {
     PowerPoint.Selection sel = app.ActiveWindow.Selection;
     if (sel.Type == PowerPoint.PpSelectionType.ppSelectionNone)
     {
         MessageBox.Show("请先选中要复制的形状");
     }
     else
     {
         PowerPoint.Slide      slide = app.ActiveWindow.View.Slide;
         PowerPoint.ShapeRange range = sel.ShapeRange;
         if (sel.HasChildShapeRange)
         {
             range = sel.ChildShapeRange;
         }
         float rn     = float.Parse(textBox2.Text);
         int   scount = int.Parse(textBox3.Text);
         oshape = range[1];
         for (int i = 1; i <= scount; i++)
         {
             PowerPoint.Shape nshape = oshape.Duplicate()[1];
             nshape.Rotation = oshape.Rotation + i * rn;
             nshape.Left     = oshape.Left;
             nshape.Top      = oshape.Top;
             nshape.Select();
         }
     }
 }
Beispiel #14
0
        private void button1_Click(object sender, EventArgs e)
        {
            PowerPoint.Selection sel = app.ActiveWindow.Selection;
            if (sel.Type == PowerPoint.PpSelectionType.ppSelectionNone)
            {
                MessageBox.Show("请先选中一个形状");
            }
            else
            {
                PowerPoint.Slide      slide = app.ActiveWindow.View.Slide;
                PowerPoint.ShapeRange range = sel.ShapeRange;
                if (sel.HasChildShapeRange)
                {
                    range = sel.ChildShapeRange;
                }
                else
                {
                    range = sel.ShapeRange;
                }
                int count = range.Count;

                for (int i = 1; i <= count; i++)
                {
                    PowerPoint.Shape shape = range[i];
                    shape.Rotation = float.Parse(textBox1.Text);
                }
            }
        }
        /**
         * Compares between 2 slides
         *
         * Changes in slides may sometimes be too minute for detection
         * Bump up the threshold or compare them manually if so
         */
        protected void CompareSlides(int actualShapesSlideNo, int expectedShapesSlideNo, double tolerance = 0.95)
        {
            PowerPoint.Slide actualSlide   = PpOperations.SelectSlide(actualShapesSlideNo);
            PowerPoint.Slide expectedSlide = PpOperations.SelectSlide(expectedShapesSlideNo);

            SlideUtil.IsSameLooking(actualSlide, expectedSlide, tolerance);
        }
 void Application_PresentationNewSlide(PowerPoint.Slide Sld)
 {
     /*PowerPoint.Shape textBox = Sld.Shapes.AddTextbox(
      *  Office.MsoTextOrientation.msoTextOrientationHorizontal, 0, 0, 500, 50);
      * textBox.TextFrame.TextRange.InsertAfter("This text was added by using code.");*/
     //MessageBox.Show("New slide!");
 }
Beispiel #17
0
 private void ButtonUP_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         slideIndex = slide.SlideIndex - 1;
     }
     catch
     {
         WdMessageBox.Display("Error", "PPT已关闭", "真是不幸");
         App.Current.Shutdown();
     }
     if (slideIndex >= 1)
     {
         try
         {
             slide = slides[slideIndex];
             slides[slideIndex].Select();
         }
         catch
         {
             // 在阅读模式下使用下面的方式来切换到上一张幻灯片
             pptApplication.SlideShowWindows[1].View.Previous();
             slide = pptApplication.SlideShowWindows[1].View.Slide;
         }
     }
     else
     {
         slideIndex = 1;
         WdMessageBox.Display("Info", "已经到了第一页", "", "", "哦");
     }
     UpdateSlideIndex();
 }
Beispiel #18
0
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            //Add a blank slide
            PowerPoint.Slide sld = Application.ActivePresentation.Slides[0];

            //Add a 15 x 15 table
            PowerPoint.Shape shp = sld.Shapes.AddTable(15, 15, 10, 10, 200, 300);
            PowerPoint.Table tbl = shp.Table;
            int i = -1;
            int j = -1;

            //Loop through all the rows
            foreach (PowerPoint.Row row in tbl.Rows)
            {
                i = i + 1;
                j = -1;

                //Loop through all the cells in the row
                foreach (PowerPoint.Cell cell in row.Cells)
                {
                    j = j + 1;
                    //Get text frame of each cell
                    PowerPoint.TextFrame tf = cell.Shape.TextFrame;
                    //Add some text
                    tf.TextRange.Text = "T" + i.ToString() + j.ToString();
                    //Set font size of the text as 10
                    tf.TextRange.Paragraphs(0, tf.TextRange.Text.Length).Font.Size = 10;
                }
            }
        }
Beispiel #19
0
 /// <summary>
 /// 刷新ppt的index
 /// </summary>
 private void UpdateSlideIndex()
 {
     try
     {
         // 在普通视图下这种方式可以获得当前选中的幻灯片对象
         // 然而在阅读模式下,这种方式会出现异常
         slide = slides[pptApplication.ActiveWindow.Selection.SlideRange.SlideNumber];
         //lastslide = slide;
         slideIndex = slide.SlideIndex;
     }
     catch
     {
         try
         {
             // 在阅读模式下出现异常时,通过下面的方式来获得当前选中的幻灯片对象
             slide      = pptApplication.SlideShowWindows[1].View.Slide;
             slideIndex = slide.SlideIndex;
         }
         catch
         {
             Console.WriteLine("Fail UpdateSlideIndex");
         }
     }
     finally
     {
         UpdateInks();
     }
 }
 public void AddSlide(int index, POWERPOINT.PpSlideLayout layout)
 {
     if (m_PptPresSet != null)
     {
         m_CurSlide = m_PptPresSet.Slides.Add(index, layout);
     }
 }
        private void DeleteSlide(int index)
        {
            //TODO: try-catch
            PPT.Application   app  = new PPT.Application();
            PPT.Presentations pres = app.Presentations;

            PPT.Presentation pptx = pres.Open(LibraryFile.FullPath, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);

            PPT.Slides slides = pptx.Slides;
            PPT.Slide  slide  = slides[index];

            slide.Delete();

            pptx.Save();
            pptx.Close();

            slide.ReleaseCOM();
            slide = null;

            slides.ReleaseCOM();
            slides = null;

            pptx.ReleaseCOM();
            pptx = null;

            pres.ReleaseCOM();
            pres = null;

            app.ReleaseCOM();
            app = null;
        }
Beispiel #22
0
        public static void ApplyIcon(Object data)
        {
            ResourceData resourceData = data as ResourceData;

            if (resourceData != null)
            {
                string  strUrl  = resourceData.FileUrl;
                string  strPath = Request.HttpDownload(strUrl).Result;
                JObject jObject = new JObject();
                jObject.Add("sjh", Rigel.UserID);
                jObject.Add("lb", App.ResourceType.ToString());
                jObject.Add("tmid", resourceData.ID);
                String strAPI = "{0}/ppttools/lsjl/save?token={1}";
                String url    = String.Format(strAPI, Rigel.ServerUrl, Rigel.UserToken);
                Request.HttpPost(jObject, url);
                Image image = Image.FromFile(strPath);

                PowerPoint.Slide slide = Globals.ThisAddIn.Application.ActiveWindow.View.Slide;
                if (slide != null)
                {
                    PowerPoint.Shape shape = slide.Shapes.AddPicture(strPath,
                                                                     Microsoft.Office.Core.MsoTriState.msoFalse,
                                                                     Microsoft.Office.Core.MsoTriState.msoCTrue, 50, 50);

                    /* if(shape != null && slide.ColorScheme.Count > 0)
                     * {
                     *   PowerPoint.RGBColor color = slide.ColorScheme._Index(slide.ColorScheme.Count) as PowerPoint.RGBColor;
                     *   shape.Fill.ForeColor.RGB = color.RGB;
                     * }*/
                }
            }
        }
 private PowerPointSpotlightSlide(PowerPoint.Slide slide) : base(slide)
 {
     if (!slide.Name.Contains("PPTLabsSpotlight"))
     {
         _slide.Name = "PPTLabsSpotlight" + DateTime.Now.ToString("yyyyMMddHHmmssffff");
     }
 }
Beispiel #24
0
 internal static Boolean CheckObjectsExist()
 {
     PowerPoint.Slides slides = Globals.ThisAddIn.Application.ActivePresentation.Slides;
     foreach (PowerPoint.Slide slide in slides)
     {
         PowerPoint.Slide currSlide = slides[slide.SlideIndex];
         foreach (PowerPoint.Shape shape in currSlide.Shapes)
         {
             if (shape.Type.Equals(Office.MsoShapeType.msoTextBox))
             {
                 if (shape.TextFrame.TextRange.Font.Color.RGB.Equals(9109675))
                 {
                     return(true);
                 }
             }
             else if (shape.Type.Equals(Office.MsoShapeType.msoInkComment))
             {
                 if (shape.Line.ForeColor.RGB.Equals(9109675))
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Beispiel #25
0
        private void buttonUpdateAllSlides_Click(object sender, RibbonControlEventArgs e)
        {
            string slideNotes = string.Empty;

            PowerPoint.Slide slide = Globals.ThisAddIn.Application.ActiveWindow.View.Slide;

            if (null != slide)
            {
                if (slide.HasNotesPage == Office.MsoTriState.msoTrue)
                {
                    PowerPoint.SlideRange notesPages = slide.NotesPage;
                    foreach (PowerPoint.Shape shape in notesPages.Shapes)
                    {
                        if (shape.Type == Office.MsoShapeType.msoPlaceholder)
                        {
                            if (shape.PlaceholderFormat.Type == PowerPoint.PpPlaceholderType.ppPlaceholderBody)
                            {
                                slideNotes = shape.TextFrame.TextRange.Text;
                                break;
                            }
                        }
                    }
                }
            }

            PowerPoint.Presentation presentation = Globals.ThisAddIn.Application.ActivePresentation;
            foreach (PowerPoint.Slide presentationSlide in presentation.Slides)
            {
                presentationSlide.Select();
                UpdateCurrentSlide();
            }
        }
Beispiel #26
0
        public void createFile(string filepath)
        {
            if (filepath.EndsWith(".xlsx"))
            {
                Microsoft.Office.Interop.Excel.Application ExcelApp = new Microsoft.Office.Interop.Excel.Application();
                Workbook ExcelWorkBook = null;
                ExcelApp.Visible       = false;
                ExcelApp.DisplayAlerts = false;

                ExcelWorkBook = ExcelApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
                ExcelWorkBook.SaveAs(filepath);
                ExcelWorkBook.Close();
                ExcelApp.Quit();
            }
            else if (filepath.EndsWith(".pptx"))
            {
                Application pptApplication = new Application();
                // Create the Presentation File
                Presentation pptPresentation = pptApplication.Presentations.Add(MsoTriState.msoTrue);
                Microsoft.Office.Interop.PowerPoint.CustomLayout customLayout = pptPresentation.SlideMaster.CustomLayouts[Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutText];

                Microsoft.Office.Interop.PowerPoint.Slides slides = pptPresentation.Slides;
                Microsoft.Office.Interop.PowerPoint.Slide  slide  = slides.AddSlide(1, customLayout);
                pptPresentation.SaveAs(filepath, Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsDefault, MsoTriState.msoTrue);
                pptPresentation.Close();
                pptApplication.Quit();
            }
            else
            {
                File.Create(filepath).Close();
            }
        }
Beispiel #27
0
        private void testCode()
        {
            // Create a PowerPoint application object.
            PowerPoint.Application appPPT = Globals.ThisAddIn.Application;

            // Create a new PowerPoint presentation.
            PowerPoint.Presentation pptPresentation = appPPT.ActivePresentation;


            PowerPoint.CustomLayout pptLayout = default(PowerPoint.CustomLayout);
            if ((pptPresentation.SlideMaster.CustomLayouts._Index(7) == null))
            {
                pptLayout = pptPresentation.SlideMaster.CustomLayouts._Index(1);
            }
            else
            {
                pptLayout = pptPresentation.SlideMaster.CustomLayouts._Index(7);
            }

            // Create newSlide by using pptLayout.
            PowerPoint.Slide newSlide =
                pptPresentation.Slides.AddSlide((pptPresentation.Slides.Count + 1), pptLayout);

            Color myBackgroundColor = Color.Aqua;
            int   oleColor          = ColorTranslator.ToOle(myBackgroundColor);

            newSlide.FollowMasterBackground        = Core.MsoTriState.msoFalse;
            newSlide.Background.Fill.ForeColor.RGB = oleColor;
            //newSlide.Background.Fill.Visible = Core.MsoTriState.msoFalse;


            PowerPoint.Shape textBox = newSlide.Shapes.AddTextbox(Core.MsoTextOrientation.msoTextOrientationHorizontal, 100, 100, 500, 100);

            textBox.TextFrame.TextRange.Text = "teasdfst";
        }
Beispiel #28
0
 private static void fix_quotes_slide(PP.Slide slide)
 {
     foreach (PP.Shape shape in slide.Shapes)
     {
         fix_quotes_shape(shape);
     }
 }
Beispiel #29
0
        private void AssertIsSame(int originalSlideNo, int expectedSlideNo, Presentation expectedPresentation)
        {
            Microsoft.Office.Interop.PowerPoint.Slide originalSlide = PpOperations.SelectSlide(originalSlideNo);
            Microsoft.Office.Interop.PowerPoint.Slide expectedSlide = expectedPresentation.Slides[expectedSlideNo];

            SlideUtil.IsSameLooking(expectedSlide, originalSlide);
            SlideUtil.IsSameAnimations(expectedSlide, originalSlide);
        }
Beispiel #30
0
        private PowerPoint.Slide AddASlide(PowerPoint.Presentation ppPresentation, int slidePosition, string slideLayout)
        {
            PowerPoint.Slide ppSlide = null;

            ppSlide = ppPresentation.Slides.AddSlide(slidePosition, GetCustomLayout(ppPresentation, slideLayout));

            return(ppSlide);
        }
Beispiel #31
0
 public static bool IsAckSlide(PowerPoint.Slide slide)
 {
     if (slide == null)
     {
         return(false);
     }
     return(IsAckSlide(slide.Name));
 }
Beispiel #32
0
 protected void lbLast_Click(object sender, EventArgs e)
 {
     try
     {
         slides[slidescount].Select();
         slide = slides[slidescount];
     }
     catch
     {
         pptApplication.SlideShowWindows[1].View.Last();
         slide = pptApplication.SlideShowWindows[1].View.Slide;
     }
 }
 public void GoLastSlide()
 {
     try
     {
         slides[slidescount].Select();
         slide = slides[slidescount];
     }
     catch
     {
         pptApplication.SlideShowWindows[1].View.Last();
         slide = pptApplication.SlideShowWindows[1].View.Slide;
     }
 }
 public void GoFirstSlide()
 {
     try
     {
         // Call Select method to select first slide in normal view
         slides[1].Select();
         slide = slides[1];
     }
     catch
     {
         // Transform to first page in reading view
         pptApplication.SlideShowWindows[1].View.First();
         slide = pptApplication.SlideShowWindows[1].View.Slide;
     }
 }
Beispiel #35
0
 protected void lbFirst_Click(object sender, EventArgs e)
 {
     try
     {
         // Call Select method to select first slide in normal view
         slides[1].Select();
         slide = slides[1];
     }
     catch
     {
         // Transform to first page in reading view
         pptApplication.SlideShowWindows[1].View.First();
         slide = pptApplication.SlideShowWindows[1].View.Slide;
     }
 }
        public void GoToSlide(int slideNumber)
        {
            if(slideNumber <= slidesCount && slideNumber > 0)
             {
                 try
                 {
                     slide = slides[slideNumber];
                     slides[slideNumber].Select();
                 }
                 catch
                 {
                     pptApplication.SlideShowWindows[slideNumber].View.Previous();
                     slide = pptApplication.SlideShowWindows[slideNumber].View.Slide;
                 }

             }
        }
Beispiel #37
0
        protected void lbNext_Click(object sender, EventArgs e)
        {
            slideIndex = slide.SlideIndex + 1;
            if (slideIndex > slidescount)
            {

            }
            else
            {
                try
                {
                    slide = slides[slideIndex];
                    slides[slideIndex].Select();
                }
                catch
                {
                    pptApplication.SlideShowWindows[1].View.Next();
                    slide = pptApplication.SlideShowWindows[1].View.Slide;
                }
            }
        }
        public bool GetOpenPpt()
        {
            bool success = false;
            try
            {
                // Get Running PowerPoint Application object
                pptApplication = Marshal.GetActiveObject("PowerPoint.Application") as PowerPoint.Application;
            }
            catch
            {

            }

            if (pptApplication != null)
            {
                success = true;

                // Get Presentation Object
                presentation = pptApplication.ActivePresentation;
                // Get Slide collection object
                slides = presentation.Slides;
                // Get Slide count
                slidesCount = slides.Count;
                // Get current selected slide
                try
                {
                    // Get selected slide object in normal view
                    slide = slides[pptApplication.ActiveWindow.Selection.SlideRange.SlideNumber];
                }
                catch
                {
                    // Get selected slide object in reading view
                    slide = pptApplication.SlideShowWindows[1].View.Slide;
                }
            }

            return success;
        }
        public void GoNextSlide()
        {
            slideIndex = slide.SlideIndex + 1;
            if (slideIndex <= slidescount)
            {
                try
                {
                    //standard mode
                    //slide = slides[slideIndex];
                    //slides[slideIndex].Select();

                    Logger.Log("Siguiente Diapositiva");

                    //fullscreen mode
                    if (pptApplication.SlideShowWindows.Count > 0)
                    {
                        pptApplication.SlideShowWindows[1].View.Next(); //TODO que pasa si hay mas de una ppt en fullscrenn? por ejemplo 2 monitores
                        slide = pptApplication.SlideShowWindows[1].View.Slide;
                    }
                }
                catch(Exception ex)
                {
                    Logger.LogError("Error slide siguiente: " + ex.Message);
                }
            }
        }
Beispiel #40
0
 //
 //**********************************************************************************************
 //
 public void AddPictureToSlide(String aFile)
 {
     MySlide = MySlides.Add(MySlides.Count+1, PowerPoint.PpSlideLayout.ppLayoutBlank);
       MySlide.Shapes.AddPicture(aFile, MsoTriState.msoFalse, MsoTriState.msoTrue, 0, 0, 800, 600);
 }
Beispiel #41
0
 //评分核心函数
 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;
 }
        public void Init()
        {
            try
            {
                // Get Running PowerPoint Application object
                pptApplication = Marshal.GetActiveObject("PowerPoint.Application") as PPt.Application;
                pptApplication.SlideShowBegin += pptApplication_SlideShowBegin;
                pptApplication.SlideShowEnd += pptApplication_SlideShowEnd;

                if (pptApplication != null)
                {
                    try
                    {
                        // Get Presentation Object
                        presentation = pptApplication.ActivePresentation;
                        if(PlayPresentation)
                            presentation.SlideShowSettings.Run();
                    }
                    catch
                    {
                        // Get presentation in protected mode
                        presentation = pptApplication.ActiveProtectedViewWindow.Presentation;
                        if (PlayPresentation)
                            presentation.SlideShowSettings.Run();
                    }
                    //// Get Slide collection object
                    slides = presentation.Slides;
                    //// Get Slide count
                    slidescount = slides.Count;
                    //// Get current selected slide
                    try
                    {
                        // Get selected slide object in normal view
                        slide = slides[pptApplication.ActiveWindow.Selection.SlideRange.SlideNumber];
                    }
                    catch
                    {
                        // Get selected slide object in reading view
                        slide = pptApplication.SlideShowWindows[1].View.Slide;
                    }
                }
            }
            catch
            {
                //TODO
            }
        }
        /// <summary>
        /// Build slide content
        /// </summary>
        /// <param name="slide">Slide in PowerPoint presentation</param>
        /// <param name="slideNode">Node containing content of slide</param>
        /// <param name="passNumber">Number of current pass (used for overlays)</param>
        /// <param name="pauseCounter">Number of used pauses</param>
        /// <param name="paused">output - processing of slide content was paused</param>
        /// <returns>true if slide is complete; false if needs another pass</returns>
        public bool BuildSlide(PowerPoint.Slide slide, Node slideNode, int passNumber, int pauseCounter, out bool paused)
        {
            _slide = slide;
            _passNumber = passNumber;
            _pauseCounter = pauseCounter;
            // copy title settings
            _titlesettings = new Dictionary<string,List<Node>>(_preambuleSettings.TitlepageSettings);
            _format = new TextFormat(_baseFontSize);
            _postProcessing = new Queue<Node>();

            if (!_called)
            {
                // because title is processed before slide and can contain pause command, we need to setup internal counters according to title passed at first processing
                _localPauseCounter = pauseCounter;
                _localPauseCounterStart = pauseCounter;
                _maxPass = passNumber;
                _called = true;
            }
            else
            {
                _localPauseCounter = _localPauseCounterStart;
            }

            _bottomShapeBorder = 0.0f;

            UpdateBottomShapeBorder();

            paused = !ProcessSlideContent(slideNode);

            if (!Settings.Instance.NestedAsText)    // extract nested elements
            {
                _localPauseCounter = int.MinValue;  // ignore pauses in post processed shapes
                PostProcessing();
            }

            return _passNumber >= _maxPass;
        }
Beispiel #44
0
        private void AfterCopyEventHandler(PowerPoint.Selection selection)
        {
            try
            {
                _copyFromWnd = Application.ActiveWindow;

                if (selection.Type == PowerPoint.PpSelectionType.ppSelectionSlides)
                {
                    _copiedSlides.Clear();

                    foreach (var sld in selection.SlideRange)
                    {
                        var slide = sld as PowerPoint.Slide;

                        _copiedSlides.Add(slide);
                    }

                    _copiedSlides.Sort((x, y) => (x.SlideIndex - y.SlideIndex));
                }
                else if (selection.Type == PowerPoint.PpSelectionType.ppSelectionShapes)
                {
                    _copiedShapes.Clear();
                    _previousSlideForCopyEvent = Application.ActiveWindow.View.Slide as PowerPoint.Slide;
                    _previousPptName = Application.ActivePresentation.Name;
                    foreach (var sh in selection.ShapeRange)
                    {
                        var shape = sh as PowerPoint.Shape;
                        _copiedShapes.Add(shape);
                    }

                    _copiedShapes.Sort((x, y) => (x.Id - y.Id));
                }
            }
            catch
            {
                //TODO: log in ThisAddIn.cs
            }
        }
        private PowerPoint.Slide AddSlideByQuestionnaire(QuestionnaireModel questionnaire)
        {
            var index = Globals.ThisAddIn.Application.ActivePresentation.Slides.Count + 1;

            var slide = AppWapper.App.ActivePresentation.Slides.Add(index, PowerPoint.PpSlideLayout.ppLayoutBlank);

            var textbox = slide.Shapes.AddTextbox(Office.MsoTextOrientation.msoTextOrientationHorizontal, 50, 50, 600, 50);//向当前PPT添加文本框
            textbox.TextFrame.TextRange.Text = "调查:";
            textbox.TextFrame.TextRange.Font.Size = 48;//设置文本字体大小

            for (var i = 0; i < questionnaire.choices; i++)
            {
                var choiceTextbox = slide.Shapes.AddTextbox(Office.MsoTextOrientation.msoTextOrientationHorizontal, 50, 120 + 40 * i, 400, 50);//向当前PPT添加文本框
                choiceTextbox.TextFrame.TextRange.Text = ChoiceString[i] + ":";
                choiceTextbox.TextFrame.TextRange.Font.Size = 24;//设置文本字体大小
            }

            _selectedSlide = slide;

            return _selectedSlide;
        }
Beispiel #46
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                // Get Running PowerPoint Application object
                pptApplication = System.Runtime.InteropServices.Marshal.GetActiveObject("PowerPoint.Application") as PPt.Application;
            }
            catch
            {

            }
            if (pptApplication != null)
            {
                // Get Presentation Object
                presentation = pptApplication.ActivePresentation;
                // Get Slide collection object
                slides = presentation.Slides;
                // Get Slide count
                slidescount = slides.Count;
                // Get current selected slide
                try
                {
                    // Get selected slide object in normal view
                    slide = slides[pptApplication.ActiveWindow.Selection.SlideRange.SlideNumber];
                }
                catch
                {
                    // Get selected slide object in reading view
                    slide = pptApplication.SlideShowWindows[1].View.Slide;
                }
            }
        }
Beispiel #47
0
 protected void lbPrev_Click(object sender, EventArgs e)
 {
     slideIndex = slide.SlideIndex - 1;
     if (slideIndex >= 1)
     {
         try
         {
             slide = slides[slideIndex];
             slides[slideIndex].Select();
         }
         catch
         {
             pptApplication.SlideShowWindows[1].View.Previous();
             slide = pptApplication.SlideShowWindows[1].View.Slide;
         }
     }
 }
 private void App_SlideSelectionChanged(PowerPoint.SlideRange SldRange)
 {
     if (SldRange.Count != 1)
     {
         _selectedSlide = null;
     }
     else
     {
         _selectedSlide = SldRange[1];
     }
     RefreshSetAndAdd();
 }
Beispiel #49
0
 private void btnPrevious_Click(object sender, EventArgs e)
 {
     slideIndex = slide.SlideIndex - 1;
     if (slideIndex >= 1)
     {
         try
         {
             slide = slides[slideIndex];
             slides[slideIndex].Select();
         }
         catch
         {
             pptApplication.SlideShowWindows[1].View.Previous();
             slide = pptApplication.SlideShowWindows[1].View.Slide;
         }
     }
     else
     {
         MessageBox.Show("It is already Fist Page");
     }
 }
Beispiel #50
0
 private void btnNext_Click(object sender, EventArgs e)
 {
     slideIndex = slide.SlideIndex + 1;
     if (slideIndex > slidescount)
     {
         MessageBox.Show("It is already last page");
     }
     else
     {
         try
         {
             slide = slides[slideIndex];
             slides[slideIndex].Select();
         }
         catch
         {
             pptApplication.SlideShowWindows[1].View.Next();
             slide = pptApplication.SlideShowWindows[1].View.Slide;
         }
     }
 }