Пример #1
0
        private void ReadSlide(object sender, EventArgs e)
        {
            if (NoPowerPoint())
            {
                ofd = new OpenFileDialog {
                    Filter = powerpointformat
                };
                try
                { if (ofd.ShowDialog() == DialogResult.OK)
                  {
                      file_path = ofd.FileName;
                  }
                  else
                  {
                      return;
                  } } catch (SystemException exc)
                { MessageBox.Show(open_err_msg + ofd.FileName + ":\n\n" + exc);
                  return; } finally { ofd.Dispose(); }

                PowerPoint_App      = new Ppt.Application();
                multi_presentations = PowerPoint_App.Presentations;
                presentation        = multi_presentations.Open(file_path, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoTrue);
            }

            TitleBox.Text    = string.Empty;
            BodyTextBox.Text = string.Empty;
            layout           = Active_slide.Layout;

            if (layout == Ppt.PpSlideLayout.ppLayoutText)
            {
                TitleBox.Text    = Active_slide.Shapes[1].TextFrame.TextRange.Text;
                BodyTextBox.Text = Active_slide.Shapes[2].TextFrame.TextRange.Text;
            }
            else
            {
                foreach (var item in presentation.Slides[1].Shapes)
                {
                    var shape = (Ppt.Shape)item;
                    if (shape.HasTextFrame != MsoTriState.msoTrue)
                    {
                        continue;
                    }

                    if (shape.Name.Contains("Title"))
                    {
                        TitleBox.Text += shape.TextFrame.TextRange.Text + ' ';
                        box_list.Insert(0, shape.Name);
                    }

                    else if (shape.TextFrame.HasText == MsoTriState.msoTrue)
                    {
                        IDataObject clipped = Clipboard.GetDataObject();
                        shape.TextFrame.TextRange.Copy();
                        BodyTextBox.Paste();
                        Clipboard.SetDataObject(clipped, true);
                        box_list.Add(shape.Name);
                    }
                }
            }
        }
Пример #2
0
 public void AddSlide(int index, POWERPOINT.PpSlideLayout layout)
 {
     if (m_PptPresSet != null)
     {
         m_CurSlide = m_PptPresSet.Slides.Add(index, layout);
     }
 }
Пример #3
0
 private void CreateNewPresentation()
 {
     PowerPoint_App      = new Ppt.Application();
     multi_presentations = PowerPoint_App.Presentations;
     presentation        = multi_presentations.Add();
     layout = Ppt.PpSlideLayout.ppLayoutText;
     presentation.Slides.AddSlide(1, presentation.SlideMaster.CustomLayouts[layout]);
 }
Пример #4
0
        private bool CreateNewPresentation()
        {
            SaveFileDialog sfd = new SaveFileDialog {
                Filter = powerpointformat
            };

            try
            { if (sfd.ShowDialog() == DialogResult.OK)
              {
                  file_path = sfd.FileName;
              }
              else
              {
                  return(false);
              } } catch (SystemException exc)
            { MessageBox.Show(save_err_msg + sfd.FileName + ":\n\n" + exc);
              return(false); } finally { sfd.Dispose(); }

            presentation = presentation_list.Add();
            layout       = Ppt.PpSlideLayout.ppLayoutText;
            presentation.Slides.AddSlide(1, presentation.SlideMaster.CustomLayouts[layout]);
            ChangeButtons();
            return(true);
        }
Пример #5
0
 /// <summary>
 ///     Set the slide layout using one of PowerPoints builtin in layout templates
 /// </summary>
 /// <param name="slide">PPT.Slide object instance</param>
 /// <param name="slideLayout">PPT.PpSlideLayout to apply</param>
 /// <returns></returns>
 public PPT.Slide SlideLayout(PPT.Slide slide, PPT.PpSlideLayout slideLayout)
 {
     slide.Layout = slideLayout;
     return(slide);
 }
Пример #6
0
 public void AddSlide(POWERPOINT.PpSlideLayout layout)
 {
     AddSlide(m_SlideCount++, layout);
 }
Пример #7
0
        public void InsertSlide(int slidePosition, string titleText, string slideText, string layout)
        {
            PowerPoint.PpSlideLayout slideLayout = PowerPoint.PpSlideLayout.ppLayoutTitle;
            switch (layout)
            {
            case "ContentWithCaption":
                slideLayout = PowerPoint.PpSlideLayout.ppLayoutTitle;
                break;

            case "TitleOnly":
                slideLayout = PowerPoint.PpSlideLayout.ppLayoutTitleOnly;
                break;

            case "Title":
                slideLayout = PowerPoint.PpSlideLayout.ppLayoutTitle;
                break;

            case "ObjectAndText":
                slideLayout = PowerPoint.PpSlideLayout.ppLayoutObjectAndText;
                break;

            case "Object":
                slideLayout = PowerPoint.PpSlideLayout.ppLayoutObject;
                break;

            default:
                slideLayout = PowerPoint.PpSlideLayout.ppLayoutObject;
                break;
            }
            if (slidePosition <= oSlides.Count + 1)
            {
                oSlide = oSlides.Add(slidePosition, slideLayout);
            }
            else
            {
                RobotMessageBox.Show("Your slide insert position is incorrect. Please check your number.");
                return;
            }
            oShapes = oSlide.Shapes;
            if (titleText != "")
            {
                PowerPoint.Shape     oShape    = oShapes[1];
                PowerPoint.TextFrame oTxtFrame = oShape.TextFrame;
                PowerPoint.TextRange oTxtRange = oTxtFrame.TextRange;
                oTxtRange.Text = titleText;
            }
            if (slideText != "")
            {
                if (oShapes[2] != null)
                {
                    PowerPoint.Shape     oShape    = oShapes[2];
                    PowerPoint.TextFrame oTxtFrame = oShape.TextFrame;
                    PowerPoint.TextRange oTxtRange = oTxtFrame.TextRange;
                    oTxtRange.Text = slideText;
                }
                else
                {
                    RobotMessageBox.Show("There is no element to add your text to. Have you selected appropriate slide layout?");
                }
            }
        }