public override void Convert(String inputFile, String outputFile)
        {
            try
            {
                if (!File.Exists(inputFile))
                {
                    throw new ConvertException("File not Exists");
                }

                if (IsPasswordProtected(inputFile))
                {
                    throw new ConvertException("Password Exist");
                }

                app = new PowerPoint.Application();
                presentations = app.Presentations;
                presentation = presentations.Open(inputFile, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);
                presentation.ExportAsFixedFormat(outputFile, PowerPoint.PpFixedFormatType.ppFixedFormatTypePDF);
                // presentation.ExportAsFixedFormat(outputFile, PowerPoint.PpFixedFormatType.ppFixedFormatTypePDF, PowerPoint.PpFixedFormatIntent.ppFixedFormatIntentScreen, MsoTriState.msoFalse, PowerPoint.PpPrintHandoutOrder.ppPrintHandoutVerticalFirst, PowerPoint.PpPrintOutputType.ppPrintOutputSlides, MsoTriState.msoFalse, null, PowerPoint.PpPrintRangeType.ppPrintAll, "", false, false, false, false, false, null);
            }
            catch (Exception e)
            {
                release();
                throw new ConvertException(e.Message);
            }
            release();
        }
示例#2
0
        /// <summary>
        /// Opens Presentation and selects slide
        /// </summary>
        /// <param name="path"></param>
        /// <param name="slideIndex"></param>
        private void OpenPresentation(string path, int slideIndex = 1)
        {
            PPT.Application   ppt             = null;
            PPT.Presentations pres            = null;
            PPT.Presentation  pptPresentation = null;

            try
            {
                ppt  = new PPT.Application();
                pres = ppt.Presentations;

                //TODO: Check if file is already opned
                pptPresentation = pres.Open(path);
                pptPresentation.Slides[slideIndex].Select();
            }
            catch (Exception)
            {
            }
            finally
            {
                pptPresentation.ReleaseCOM();
                pptPresentation = null;

                pres.ReleaseCOM();
                pres = null;

                ppt.ReleaseCOM();
                ppt = null;
            }
        }
示例#3
0
 private void ResetClassVariables()
 {
     g_PPT_Application = null;
     g_PPT_PresentationToBeProjected = null;
     g_PPT_CurrentPresentations      = null;
     g_PPT_FileLocation = String.Empty;
 }
        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;
        }
示例#5
0
 public void replaceContent(List <Segment> segments, string path)
 {
     Microsoft.Office.Interop.PowerPoint.Application   application         = new Microsoft.Office.Interop.PowerPoint.Application();
     Microsoft.Office.Interop.PowerPoint.Application   pwpApp              = new Microsoft.Office.Interop.PowerPoint.Application();
     Microsoft.Office.Interop.PowerPoint.Presentations multi_presentations = pwpApp.Presentations;
     Microsoft.Office.Interop.PowerPoint.Presentation  presentation        = multi_presentations.Open(path, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse);
     try
     {
         foreach (Segment segment in segments)
         {
             int    shape  = segment.shape;
             int    slide  = segment.slide;
             string source = segment.getTMSource();
             string target = segment.getTMTarget();
             if (!string.IsNullOrEmpty(target))
             {
                 Microsoft.Office.Interop.PowerPoint.TextRange textRange = presentation.Slides[slide].Shapes[shape].TextFrame.TextRange;
                 textRange.Replace(source, target, 0, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse);
             }
         }
         presentation.Save();
         presentation.Close();
         pwpApp.Quit();
     }
     catch (Exception ex)
     {
         presentation.Save();
         presentation.Close();
         pwpApp.Quit();
         File.Delete(path);
     }
 }
        public override void Convert(String inputFile, String outputFile)
        {
            try
            {
                if (!File.Exists(inputFile))
                {
                    throw new ConvertException("File not Exists");
                }

                if (IsPasswordProtected(inputFile))
                {
                    throw new ConvertException("Password Exist");
                }

                app           = new PowerPoint.Application();
                presentations = app.Presentations;
                presentation  = presentations.Open(inputFile, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);
                presentation.ExportAsFixedFormat(outputFile, PowerPoint.PpFixedFormatType.ppFixedFormatTypePDF);
                // presentation.ExportAsFixedFormat(outputFile, PowerPoint.PpFixedFormatType.ppFixedFormatTypePDF, PowerPoint.PpFixedFormatIntent.ppFixedFormatIntentScreen, MsoTriState.msoFalse, PowerPoint.PpPrintHandoutOrder.ppPrintHandoutVerticalFirst, PowerPoint.PpPrintOutputType.ppPrintOutputSlides, MsoTriState.msoFalse, null, PowerPoint.PpPrintRangeType.ppPrintAll, "", false, false, false, false, false, null);
            }
            catch (Exception e)
            {
                release();
                throw new ConvertException(e.Message);
            }
            release();
        }
示例#7
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);
                    }
                }
            }
        }
示例#8
0
        private void Form2_Load(object sender, EventArgs e)
        {
            string fileName   = @"C:\Users\Tridip\Desktop\KPIDashBoard20170125 125513.pptx";
            string exportName = "video_of_presentation";
            string exportPath = @"D:\test\Export\{0}.wmv";

            Microsoft.Office.Interop.PowerPoint.Application ppApp = new Microsoft.Office.Interop.PowerPoint.Application();
            ppApp.Visible     = Microsoft.Office.Core.MsoTriState.msoTrue;
            ppApp.WindowState = PpWindowState.ppWindowMinimized;
            Microsoft.Office.Interop.PowerPoint.Presentations oPresSet = ppApp.Presentations;
            Microsoft.Office.Interop.PowerPoint._Presentation oPres    = oPresSet.Open(fileName,
                                                                                       Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse,
                                                                                       Microsoft.Office.Core.MsoTriState.msoFalse);
            try
            {
                //oPres.CreateVideo(exportName);
                oPres.SaveCopyAs(String.Format(exportPath, exportName),
                                 Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsEMF,
                                 Microsoft.Office.Core.MsoTriState.msoCTrue);
            }
            finally
            {
                ppApp.Quit();
            }
        }
示例#9
0
        public void CopySlide(string str, Boolean worship)
        {
            string filePath = "";

            if (worship)
            {
                filePath = InnerBox.ListRoot + "\\" + "찬양집" + "\\" + str;
            }
            else
            {
                filePath = InnerBox.ListRoot + "\\" + "새찬송가" + "\\" + str;
            }

            PowerPoint.Application   CurrentApplication = Globals.ThisAddIn.Application;
            PowerPoint.Presentations currentPTs         = CurrentApplication.Presentations;
            PowerPoint.Presentation  currentPT          = CurrentApplication.ActivePresentation;
            PowerPoint.Presentation  copyPT             = currentPTs.Open(filePath, Core.MsoTriState.msoTrue, Core.MsoTriState.msoTrue, Core.MsoTriState.msoFalse);

            for (var i = 1; i <= copyPT.Slides.Count; i++)
            {
                copyPT.Slides[i].Copy();
                currentPT.Slides.Paste(currentPT.Slides.Count + 1).Design = copyPT.Slides[i].Design;
                currentPT.Slides[currentPT.Slides.Count].Shapes.Title.TextFrame.TextRange.Font.NameFarEast = "나눔고딕";
                currentPT.Slides[currentPT.Slides.Count].Shapes[1].TextFrame.TextRange.Font.NameFarEast    = "나눔고딕";
            }
        }
示例#10
0
 public void PptAction(PptDetails pptDetails)
 {
     pptDetailsMain = pptDetails;
     DodoMediaPlayer.Stop();
     this.Hide();
     if (pptDetails != null)
     {
         try
         {
             //Create a new presentation based on a template.
             objApp = new powerpointinterop.Application();
             //  objApp.SlideShowBegin += new Microsoft.Office.Interop.PowerPoint.EApplication_SlideShowBeginEventHandler(powerpnt_SlideShowBegin);
             objApp.SlideShowEnd += new Microsoft.Office.Interop.PowerPoint.EApplication_SlideShowEndEventHandler(powerpnt_SlideShowEnd);
             //objApp.SlideShowNextSlide += new Microsoft.Office.Interop.PowerPoint.EApplication_SlideShowNextSlideEventHandler(powerpnt_SlideShowNextSlide);
             objApp.Visible = MsoTriState.msoTrue;
             objPresSet     = objApp.Presentations;
             string pptName = pptDetails.Name;
             string pptPath = System.IO.Path.Combine(Mocker.debugPath, "Ppts", pptName);
             objPres   = objPresSet.Open(pptPath, MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoTrue);
             objSlides = objPres.Slides;
             objSSS    = objPres.SlideShowSettings;
             objSSS.Run();
         }
         catch (Exception)
         {
         }
     }
     else
     {
         MessageBox.Show("Media Not Found");
     }
 }
示例#11
0
        public override void Dispose()
        {
            if (_app == null)
            {
                // 已经释放,无需再释放
                return;
            }

            Console.WriteLine("关闭PowerPoint!");

            try
            {
                if (_ppts != null)
                {
                    ReleaseCOMObject(_ppts);
                    _ppts = null;
                }

                _app.Quit();
                ReleaseCOMObject(_app);
                _app = null;
            }
            catch
            {
                // TODO 退出Wold程序失败
            }
        }
示例#12
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]);
 }
示例#13
0
 private void InitializePowerpointObjects()
 {
     m_pptApplication    = new PowerPoint.Application();
     m_pptPresCollection = m_pptApplication.Presentations;
     // Argument to choose whether the ppt is visible or not
     m_pptPres   = m_pptPresCollection.Add(Office.MsoTriState.msoFalse);
     m_pptSlides = m_pptPres.Slides;
 }
示例#14
0
 /// <summary>
 /// 打开被选中的幻灯片
 /// </summary>
 /// <param name="strTemplate"></param>
 private void ShowPresentation(string strTemplate)
 {
     objApp         = new PowerPoint.Application();
     objApp.Visible = MsoTriState.msoTrue;
     objPresSet     = objApp.Presentations;
     objPres        = objPresSet.Open(strTemplate,
                                      MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
     objSlides = objPres.Slides;
 }
示例#15
0
文件: TPPT.cs 项目: BFL-JGW/TDRFree
 //
 //**********************************************************************************************
 //
 // Class TPPT
 //   Part of  : TDRFree
 //   Function : Interacts with Microsoft Powerpoint to make a presentation
 //   Author   : Jan G. Wesseling
 //   Date     : April 9th, 2013
 //
 //**********************************************************************************************
 //
 public TPPT()
 {
     MyApp = new PowerPoint.Application();
       MyApp.Visible = MsoTriState.msoTrue;
       MyApp.WindowState = PowerPoint.PpWindowState.ppWindowMinimized;
     MyPresentations = MyApp.Presentations;
       MyPresentation = MyPresentations.Add(MsoTriState.msoFalse);
       MySlides = MyPresentation.Slides;
 }
示例#16
0
        private string ConvertPowerPoint(string FilePath)
        {
            try
            {
                // new object
                //objPP = new Microsoft.Office.Interop.PowerPoint.Application();
                //var objPresentation = objPP.ActivePresentation;

                // get file name
                string[] file         = FilePath.Split('\\');
                string   FullFileName = file[file.Length - 1];
                // get extension
                string[] splittedFile = FullFileName.Split('.');
                string   ext          = splittedFile[splittedFile.Length - 1].ToUpper();
                string   filename     = splittedFile[splittedFile.Length - 2].ToUpper();


                // get convert folder directory
                string convertFolder = ConfigurationManager.AppSettings["ProjectHTMLRoot"];
                object target        = HttpContext.Current.Server.MapPath(convertFolder) + GetConvertPath(FilePath) + filename + ".htm";
                object source        = FilePath;


                if (ext == "PPT" || ext == "PPTX")
                {
                    //open the file internally in word. In the method all the parameters should be passed by object reference
                    string i = source.ToString();

                    objPP = new Microsoft.Office.Interop.PowerPoint.Application();
                    objPP.DisplayAlerts = PpAlertLevel.ppAlertsNone;
                    Microsoft.Office.Interop.PowerPoint.Presentations oPresSet = objPP.Presentations;
                    Microsoft.Office.Interop.PowerPoint._Presentation oPres    = oPresSet.Open(FilePath,
                                                                                               Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse,
                                                                                               Microsoft.Office.Core.MsoTriState.msoFalse);
                    string t = target.ToString();
                    oPres.SaveAs(t, PpSaveAsFileType.ppSaveAsHTMLv3, Microsoft.Office.Core.MsoTriState.msoTrue);

                    return("../" + convertFolder + "/" + filename + ".htm");
                }
                else
                {
                    return("");
                }
            }
            catch
            {
                throw new Exception();
            }
            finally
            {
                //Close/quit word
                //objPres.Close();
                objPP.Quit();
                Marshal.ReleaseComObject(objPP);
            }
        }
示例#17
0
        private void MainForm_FormClosed(object sender,
                                         FormClosedEventArgs e)
        {
            objPres    = null;
            objPresSet = null;

            GC.Collect();
            GC.WaitForPendingFinalizers();

            oPPT.Quit();
        }
示例#18
0
        public Form1()
        {
            InitializeComponent();

            PowerPoint.Application oPPT = new PowerPoint.Application();
            oPPT.Visible       = MsoTriState.msoTrue;
            oPPT.WindowState   = PowerPoint.PpWindowState.ppWindowMinimized;
            objPresSet         = oPPT.Presentations;
            oPPT.SlideShowEnd +=
                new PowerPoint.EApplication_SlideShowEndEventHandler(oPPT_SlideShowEnd);
        }
示例#19
0
        public List <IFileItem> AppendShapes(List <PPT.Shape> srcShapes)
        {
            PPT.Application   ppt             = null;
            PPT.Presentations pres            = null;
            PPT.Presentation  pptPresentation = null;
            try
            {
                ppt  = new PPT.Application();
                pres = ppt.Presentations;

                pptPresentation = pres.Open(FullPath, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoTrue);

                PPT.DocumentWindow wnd = pptPresentation.Windows[1];
                //wnd.Height = 200;
                //wnd.Top = -200;
                wnd.WindowState = PPT.PpWindowState.ppWindowMinimized;
                wnd             = null;

                PPT.Slides gSlides    = pptPresentation.Slides;
                int        startIndex = gSlides.Count + 1;
                int        count      = 0;
                foreach (PPT.Shape shape in srcShapes)
                {
                    PPT.Slide slide = gSlides.Add(startIndex + count++, PPT.PpSlideLayout.ppLayoutBlank);
                    shape.Copy();
                    slide.Shapes.Paste();
                    slide.Tags.Add(ShapeTag.Tag, ShapeTag.Value);

                    slide.ReleaseCOM();
                    slide = null;
                }
                List <IFileItem> newItems = new List <IFileItem>();
                newItems = fileIndex.UpdateIndex(pptPresentation, startIndex);

                return(newItems);
            }
            finally
            {
                if (pptPresentation != null)
                {
                    pptPresentation.Save();
                    pptPresentation.Close();
                }
                pptPresentation.ReleaseCOM();
                pptPresentation = null;

                pres.ReleaseCOM();
                pres = null;

                ppt.ReleaseCOM();
                ppt = null;
            }
        }
示例#20
0
        private void cmdNewFile_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (FocusedRow.Data is IGroup group)
            {
                var baseName = "New file";
                var name     = baseName + ".pptx";
                int cnt      = 2;
                while (group.ContainsFile(name)) //TODO: AST: Limit number of iterations
                {
                    name = Path.Combine(baseName + $" ({cnt++})") + ".pptx";
                }
                var fullPath = Path.Combine(group.FullPath, name);


                PPT.Application   app  = null;
                PPT.Presentations pres = null;
                PPT.Presentation  ppt  = null;

                try
                {
                    app  = new PPT.Application();
                    pres = app.Presentations;

                    ppt = pres.Add(MsoTriState.msoFalse);
                    ppt.SaveAs(fullPath);
                }
                finally
                {
                    ppt?.Close();
                    ppt.ReleaseCOM();
                    ppt = null;

                    pres.ReleaseCOM();
                    pres = null;

                    app = null;
                    //TODO: AST: app is not released
                }


                var file = group.AddFile(name);
                var row  = FocusedRow;

                var newRow = dtTree.AddTreeRow(row.ID, 4, Path.GetFileNameWithoutExtension(file.Name), file, false); //TODO: AST: Move it to builder

                var node = uxTree.FindNodeByKeyID(newRow.ID);
                if (node != null)
                {
                    node.Selected = true;
                    uxTree.ShowEditor();
                }
            }
        }
示例#21
0
        public void CreateNewPPT()
        {
            application        = new PowerPoint.Application();
            pptPresentationSet = application.Presentations;
            pptPresentation    = pptPresentationSet.Open(_fileName, MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
            //customLayout = pptPresentationSet.SlideMaster.CustomLayouts[Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutText];
            pptSlides = pptPresentation.Slides;
            pptSlide  = pptSlides.AddSlide(1, customLayout);

            textRng           = pptSlide.Shapes[1].TextFrame.TextRange;
            textRng.Font.Name = textDefaultFontName;
            textRng.Font.Size = textDefaultFontSize;
        }
示例#22
0
        public List <Segment> redPPTXFile(string path, char[] delimiters)
        {
            string         filename = Path.GetFileName(path);
            List <Segment> result   = new List <Segment>();

            try
            {
                Microsoft.Office.Interop.PowerPoint.Application   application         = new Microsoft.Office.Interop.PowerPoint.Application();
                Microsoft.Office.Interop.PowerPoint.Application   pwpApp              = new Microsoft.Office.Interop.PowerPoint.Application();
                Microsoft.Office.Interop.PowerPoint.Presentations multi_presentations = pwpApp.Presentations;
                Microsoft.Office.Interop.PowerPoint.Presentation  presentation        = multi_presentations.Open(path, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse);
                foreach (Slide slide in presentation.Slides)
                {
                    int indexShape = 1;
                    foreach (Microsoft.Office.Interop.PowerPoint.Shape shape in slide.Shapes)
                    {
                        if (shape.HasTextFrame == Microsoft.Office.Core.MsoTriState.msoTrue)
                        {
                            var textFrame = shape.TextFrame;
                            if (textFrame.HasText == Microsoft.Office.Core.MsoTriState.msoTrue)
                            {
                                var           textRange = textFrame.TextRange;
                                string        text      = textRange.Text.ToString();
                                List <string> tmp       = splitTxtContentToSegment(text, delimiters);
                                foreach (string str in tmp)
                                {
                                    tm tm = new tm();
                                    tm.Source = str;
                                    int     indexSlide = slide.SlideIndex;
                                    Segment segment    = new Segment();
                                    segment.slide = indexSlide;
                                    segment.shape = indexShape;
                                    segment.file  = filename;
                                    segment.setTM(tm);
                                    result.Add(segment);
                                }
                            }
                        }
                        indexShape++;
                    }
                }

                presentation.Save();
                presentation.Close();
                pwpApp.Quit();
            }
            catch (Exception ex)
            {
            }
            return(result);
        }
 private void OpenPresentation()
 {
     _application   = new PowerPoint.Application();
     _presentations = _application.Presentations;
     GC.Collect();
     if (_ReadOnly)
     {
         _presentation = _presentations.Open(FilePath, MsoTriState.msoCTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);
     }
     else
     {
         _presentation = _presentations.Open(FilePath, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);
     }
 }
示例#24
0
        private static void GenerateVideoFromPowerPoint()
        {
            var pptApplication = new Microsoft.Office.Interop.PowerPoint.Application();

            Microsoft.Office.Interop.PowerPoint.Presentations oPresSet = pptApplication.Presentations;
            Microsoft.Office.Interop.PowerPoint._Presentation oPres    =
                oPresSet.Open(@"C:\SCBBR53W26C036262\2006 Bentley Continental Fly.pptx",
                              Microsoft.Office.Core.MsoTriState.msoFalse,
                              Microsoft.Office.Core.MsoTriState.msoFalse,
                              Microsoft.Office.Core.MsoTriState.msoTrue);

            string movie = @"C:\SCBBR53W26C036262\2006 Bentley Continental Fly.wmv";

            oPres.CreateVideo(movie, true, 4, 480, 30, 100);
        }
示例#25
0
        public Form1()
        {
            InitializeComponent();

            image_count = 10;                   //For now we're just going with 10.
            thumb_list  = new ImageList();
            image_list  = new ImageList {
                ImageSize = new Size(160, 160)
            };
            initloc = ListView1.Location;
            change  = new Size
                          (ListView1.Width - BodyTextBox.Width, TitleBox.Location.Y - ListView1.Location.Y);

            PowerPoint_App    = new Ppt.Application();
            presentation_list = PowerPoint_App.Presentations;
        }
示例#26
0
        public override void ConfigureRendering()
        {
            try
            {
                width  = dpi * 10;
                height = Convert.ToInt32(dpi * 7.5);

                oPowerPoint = new PowerPoint.Application();                                                                                        //запускаем приложение
                oPres       = oPowerPoint.Presentations;                                                                                           //презентации
                oPre        = oPres.Open(presentationPath, Office.MsoTriState.msoFalse, Office.MsoTriState.msoFalse, Office.MsoTriState.msoFalse); //открываем презентацию
                oSlides     = oPre.Slides;                                                                                                         //считываем слайды
                count       = oPre.Slides.Count;
            }
            catch (DirectoryNotFoundException)
            {
                //УВЕДОМЛЕНИЕ О ТОМ, ЧТО ПУТЬ УКАЗАН НЕВЕРНО
                return;
            }
        }
示例#27
0
        public override string Read()
        {
            try
            {
                powerPointApp = new PowerPoint.Application();
                powerPointApp.Visible = MsoTriState.msoFalse;
                multiPresentations = powerPointApp.Presentations;

                MsoTriState trueState = MsoTriState.msoTrue;
                MsoTriState falseState = MsoTriState.msoFalse;
                string filePath = (string)FilePath;

                presentation = multiPresentations.Open(filePath,
                                                       trueState,
                                                       falseState,
                                                       falseState);

                string result = string.Empty;

                for (int i = 0; i < presentation.Slides.Count; i++)
                {
                    foreach (var item in presentation.Slides[i + 1].Shapes)
                    {
                        var shape = (PowerPoint.Shape)item;
                        if (shape.HasTextFrame == MsoTriState.msoTrue && shape.TextFrame.HasText == MsoTriState.msoTrue)
                        {
                            var textRange = shape.TextFrame.TextRange;
                            result += textRange.Text;
                        }
                    }
                }

                powerPointApp.Quit();

                return result;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
示例#28
0
        public string Read()
        {
            try
            {
                powerPointApp         = new PowerPoint.Application();
                powerPointApp.Visible = MsoTriState.msoFalse;
                multiPresentations    = powerPointApp.Presentations;

                MsoTriState trueState  = MsoTriState.msoTrue;
                MsoTriState falseState = MsoTriState.msoFalse;
                string      filePath   = (string)FilePath;

                presentation = multiPresentations.Open(filePath,
                                                       trueState,
                                                       falseState,
                                                       falseState);

                string result = string.Empty;

                for (int i = 0; i < presentation.Slides.Count; i++)
                {
                    foreach (var item in presentation.Slides[i + 1].Shapes)
                    {
                        var shape = (PowerPoint.Shape)item;
                        if (shape.HasTextFrame == MsoTriState.msoTrue && shape.TextFrame.HasText == MsoTriState.msoTrue)
                        {
                            var textRange = shape.TextFrame.TextRange;
                            result += textRange.Text;
                        }
                    }
                }

                powerPointApp.Quit();

                return(result);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
示例#29
0
 public void StartPresentation()
 {
     try
     {
         LaunchApplication();
         g_PPT_CurrentPresentations      = g_PPT_Application.Presentations;
         g_PPT_PresentationToBeProjected = g_PPT_CurrentPresentations.Open(g_PPT_FileLocation, MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoFalse);
         //g_PPT_PresentationToBeProjected.SlideShowSettings.ShowPresenterView = MsoTriState.msoFalse;
         //g_PPT_PresentationToBeProjected.SlideShowSettings.StartingSlide = 1;
         //g_PPT_PresentationToBeProjected.SlideShowSettings.ShowType = PowerPoint.PpSlideShowType.ppShowTypeSpeaker;
         //g_PPT_PresentationToBeProjected.SlideShowSettings.AdvanceMode = PowerPoint.PpSlideShowAdvanceMode.ppSlideShowUseSlideTimings;
         //g_PPT_PresentationToBeProjected.SlideShowSettings.ShowWithAnimation = MsoTriState.msoTrue;
         g_PPT_PresentationToBeProjected.SlideShowSettings.Run();
         g_PPT_Application.PresentationClose += g_PPT_Application_PresentationClose;
         //g_PPT_Application.Activate();
     }
     catch (System.Runtime.InteropServices.COMException)
     {
         //Do nothing
     }
 }
示例#30
0
 public void StartPresentation()
 {
     try
     {
         LaunchApplication();
         g_PPT_CurrentPresentations = g_PPT_Application.Presentations;
         g_PPT_PresentationToBeProjected = g_PPT_CurrentPresentations.Open(g_PPT_FileLocation, MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoFalse);
         //g_PPT_PresentationToBeProjected.SlideShowSettings.ShowPresenterView = MsoTriState.msoFalse;
         //g_PPT_PresentationToBeProjected.SlideShowSettings.StartingSlide = 1;
         //g_PPT_PresentationToBeProjected.SlideShowSettings.ShowType = PowerPoint.PpSlideShowType.ppShowTypeSpeaker;
         //g_PPT_PresentationToBeProjected.SlideShowSettings.AdvanceMode = PowerPoint.PpSlideShowAdvanceMode.ppSlideShowUseSlideTimings;
         //g_PPT_PresentationToBeProjected.SlideShowSettings.ShowWithAnimation = MsoTriState.msoTrue;
         g_PPT_PresentationToBeProjected.SlideShowSettings.Run();
         g_PPT_Application.PresentationClose += g_PPT_Application_PresentationClose;
         //g_PPT_Application.Activate();
     }
     catch (System.Runtime.InteropServices.COMException)
     {
         //Do nothing
     }
 }
示例#31
0
        /// <summary>
        /// Constructor that creates the PowerPoint object, so that we can add slides to it
        /// </summary>
        public Powerpoint()
        {
            String strTemplate;
            strTemplate = Constant.ePath + "eFlash.pot";
            //strTemplate = "C:\\Program Files\\eFlash\\Data\\Media\\" + "blank.pot";

            //Create a new presentation based on a template.
            objApp = new PowerPoint.Application();
            objApp.Visible = MsoTriState.msoTrue;
            objPresSet = objApp.Presentations;
            objPres = objPresSet.Open(strTemplate,
                MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
            objSlides = objPres.Slides;

            //Prevent Office Assistant from displaying alert messages:
            bAssistantOn = objApp.Assistant.On;
            objApp.Assistant.On = false;

            //start sCount at 1
            sCount = 1;
            oCount = 1;
        }
示例#32
0
        void showPowerpoint()
        {
            pptApp = new Microsoft.Office.Interop.PowerPoint.Application();
            var directory = new DirectoryInfo(fileLocationTxt.Text);
            var myFile    = directory.GetFiles()
                            .OrderByDescending(f => f.LastWriteTime)
                            .First();
            string path = Path.Combine(myFile.Directory.FullName, myFile.Name);

            pptApp.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
            pptApp.Activate();

            ps = pptApp.Presentations;
            try
            {
                p = ps.Open(path,
                            Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue);

                pptApp.ActivePresentation.SlideShowSettings.Run();
            }
            catch { }
        }
示例#33
0
        private bool GenerateVideoFromPowerPoint(DealerViewModel dealer, CarShortViewModel car)
        {
            try
            {
                var sourcePath     = (ConfigurationHandler.DealerImages + "/" + dealer.DealerId + "/" + car.Vin + "/NormalSizeImages");
                var pptApplication = new Microsoft.Office.Interop.PowerPoint.Application();
                Microsoft.Office.Interop.PowerPoint.Presentations oPresSet = pptApplication.Presentations;
                Microsoft.Office.Interop.PowerPoint._Presentation oPres    =
                    oPresSet.Open(sourcePath + String.Format(@"\{0} {1} {2} {3}.pptx", car.ModelYear, car.Make, car.Model, car.Trim),
                                  Microsoft.Office.Core.MsoTriState.msoFalse,
                                  Microsoft.Office.Core.MsoTriState.msoFalse,
                                  Microsoft.Office.Core.MsoTriState.msoTrue);

                string movie = sourcePath + String.Format(@"\{0} {1} {2} {3}.wmv", car.ModelYear, car.Make, car.Model, car.Trim);
                oPres.CreateVideo(movie, true, 4, 480, 30, 100);
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#34
0
        /// <summary>
        /// Создать файл презентации
        /// </summary>
        /// <param name="ppFilePath">Полный путь к файлу с презентацией</param>
        /// <param name="pptFiledbId">id презентации в БД</param>
        /// <param name="archivePath">Полный путь к архиву, содержащему презентацию ()</param>
        public PPTFile(string ppFilePath, long pptFiledbId, string archivePath = null)
        {
            Microsoft.Office.Interop.PowerPoint._Application  powerPointApp   = new Microsoft.Office.Interop.PowerPoint.Application();
            Microsoft.Office.Interop.PowerPoint.Presentations ppPresentations = powerPointApp.Presentations;
            _Presentation = ppPresentations.Open(ppFilePath, MsoTriState.msoCTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);

            if (archivePath == null)
            {
                _PresentationInfo = new PresentationInfo(ppFilePath)
                {
                    SlidersInfo = new List <SlideInfo>(), DbId = pptFiledbId
                }
            }
            ;
            else
            {
                _PresentationInfo = new PresentationInfo(archivePath)
                {
                    SlidersInfo = new List <SlideInfo>(), DbId = pptFiledbId
                }
            };
        }
示例#35
0
 /*
  *      public override void SetProcessId()
  *      {
  *          if (process.HasExited)
  *          {
  *              foreach (var p in Process.GetProcesses())
  *              {
  *                  if (p.ProcessName == processName)
  *                  {
  *                      processId = p.Id;
  *                      //process = p;
  *                      break;
  *                  }
  *              }
  *          }
  *          else
  *              processId = process.Id;
  *      }
  */
 public override void Clear()
 {
     if (oSlides != null)
     {
         Marshal.FinalReleaseComObject(oSlides);
         oSlides = null;
     }
     if (oPre != null)
     {
         Marshal.FinalReleaseComObject(oPre);
         oPre = null;
     }
     if (oPres != null)
     {
         Marshal.FinalReleaseComObject(oPres);
         oPres = null;
     }
     if (oPowerPoint != null)
     {
         Marshal.FinalReleaseComObject(oPowerPoint);
         oPowerPoint = null;
     }
 }
示例#36
0
        void openPPt()
        {
            ppt = new PowerPoint.Application();
            ppt.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;

            spPt = ppt.Presentations;
            openPt = spPt.Open(pptname, MsoTriState.msoFalse, MsoTriState.msoFalse);
            openPt.SlideShowSettings.Run();
        }
示例#37
0
文件: TriggerForm.cs 项目: GCRGCR/SSV
 private void PresentationStop()
 {
     Debug.Print(System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name); //---------
     objSSS = null;
         try
         {
             objPres.Close();
         }
         catch (System.NullReferenceException)
         {
         }
         catch(Exception objException)
         {
             //MessageBox.Show("Error"+ objException.StackTrace, "Error");
         }
     objPres = null;
     objPresSet = null;
     //WinApi.ShowTray();
     Taskbar.Show();
 }
示例#38
0
        public void Start()
        {
            this.powerpoint = new PowerPoint.Application();

            if (this.powerpoint == null) return;

            this.powerpoint.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
            this.presentations = this.powerpoint.Presentations;

            this.presentation = this.presentations.Open(this.defaultPresentation,
                Microsoft.Office.Core.MsoTriState.msoFalse,
                Microsoft.Office.Core.MsoTriState.msoTrue,
                Microsoft.Office.Core.MsoTriState.msoTrue);

            this.presentation.SlideShowSettings.Run();
            this.presentation.SlideShowWindow.View.GotoSlide(this.defaultIndex);
        }
示例#39
0
        //Create a new and initialize it;s presentation
        public void Init()
        {
            objApp = new PowerPoint.Application();

            flag = 0;

            objPresSet = objApp.Presentations;
            //objPres = objPresSet.Add(MsoTriState.msoTrue);

               objPres= objPresSet.Open("c://sample.pptx");
            objSlides = objPres.Slides;
        }
示例#40
0
 private void ResetClassVariables()
 {
     g_PPT_Application = null;
     g_PPT_PresentationToBeProjected = null;
     g_PPT_CurrentPresentations = null;
     g_PPT_FileLocation = String.Empty;
 }
示例#41
0
文件: TriggerForm.cs 项目: GCRGCR/SSV
        /*      delegate void SetTextCallback(string text);
        private void SetText(string text)
        {
            Debug.Print(System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name); //---------
            // InvokeRequired required compares the thread ID of the
            // calling thread to the thread ID of the creating thread.
            // If these threads are different, it returns true.
            if (this.lblSTrigger.InvokeRequired)
            {
                SetTextCallback d = new SetTextCallback(SetText);
                this.Invoke(d, new object[] { text });
            }
            else
            {
                this.lblSTrigger.Text = text;
            }
        }                  */
        private void PresentationStart()
        {
            Debug.Print(System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name); //---------
            try
            {
                objApp = new PowerPoint.Application();
                objApp.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
                objPresSet = objApp.Presentations;
                objPres = objPresSet.Open(stSettings.strPPath, Microsoft.Office.Core.MsoTriState.msoFalse, // MsoTriState ReadOnly,
                Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue);    //MsoTriState Untitled,MsoTriState WithWindow
            }
            catch (Exception e)
            {
                this.Activate();
                MessageBox.Show(e.Message);
                tsmPresentationStop_Click(null, null);
                return;
            }

            //objSlides = objPres.Slides;

            //Run the Slide show
            objSSS = objPres.SlideShowSettings;
            objSSS.ShowType = Microsoft.Office.Interop.PowerPoint.PpSlideShowType.ppShowTypeSpeaker;
            objSSS.LoopUntilStopped = Microsoft.Office.Core.MsoTriState.msoTrue;

            if (stSettings.bytRunMacro == 0 || stSettings.strPPMacroName=="")
            {
                objSSS.Run();
            }
            else
            {
                object[] oRunArgs = new Object[] { "'" + objPres.Name + "'!" + stSettings.strPPMacroName, stSettings.strMParam1, stSettings.strMParam2, stSettings.strMParam3 };
                try
                {
                    objApp.GetType().InvokeMember("Run", System.Reflection.BindingFlags.Default | System.Reflection.BindingFlags.InvokeMethod, null, objApp, oRunArgs);
                    originalPWidth = objPres.SlideShowWindow.Width;
                }
                catch (System.Runtime.InteropServices.COMException e)
                {
                    MessageBox.Show(e.Message + "\n" + "\n" + e.Source + "\n" + e.StackTrace);
                    return;
                }
                catch (Exception e)
                {
                    this.Activate();
                    MessageBox.Show(e.Message + "\n" + "\n" + e.InnerException.Source + "\nn" + e.InnerException.Message);
                    return;
                }
            }

            //handle
            //IntPtr hwnd = new IntPtr(objPres.SlideShowWindow.HWND);
            //WindowWrapper handleWrapper = new WindowWrapper(hwnd);
            //SetParent(handleWrapper.Handle, this.Handle);
            //this.Visible = true;
            if (stSettings.bytFullScreenPres==0)
            {
                SlideShowSize();
                //WinApi.HideTray();
                Taskbar.Hide();
            }
        }
 //-------------------------------------------------------------------------------
 protected void InitializePPT()
 {
     application = (PowerPoint.ApplicationClass)Server.CreateObject("PowerPoint.Application");
      presentations = application.Presentations;
      presentation = presentations.Add(Microsoft.Office.Core.MsoTriState.msoTrue);
      slides = presentation.Slides;
 }
        public static void ShowPresentation(string path)
        {
            String strTemplate ; //, strPic;
            string Base = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;

            string LocalDir = System.IO.Path.GetDirectoryName(Base).Replace("file:\\", "");

            strTemplate = System.IO.Path.Combine(LocalDir, "Resources", "Template.pptx");
            //"\\\\flrblr001\\windows_data\\From-SLI-Fileserver\\E\\Product Engineering\\Sundar\\svn\\trunk\\CommonBase\\DeviceSpecific\\Si53300\\sample_data\\Template.pptx";
            //strPic = "C:\\Windows\\Blue Lace 16.bmp";
            //bool bAssistantOn;
            if (!System.IO.File.Exists(strTemplate)) {
                System.Windows.MessageBox.Show("Template file is missing, create the file: " + strTemplate);
            }
            //Create a new presentation based on a template.
            objApp = new PowerPoint.Application();
            objApp.Visible = MsoTriState.msoTrue;
            objPresSet = objApp.Presentations;
            objPres = objPresSet.Open(strTemplate,
              MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
            objSlides = objPres.Slides;
            objApp.WindowState = Microsoft.Office.Interop.PowerPoint.PpWindowState.ppWindowMinimized;
        }
示例#44
0
 /// <summary>
 /// 打开被选中的幻灯片
 /// </summary>
 /// <param name="strTemplate"></param>
 private void ShowPresentation(string strTemplate)
 {
     objApp = new PowerPoint.Application();
     objApp.Visible = MsoTriState.msoTrue;
     objPresSet = objApp.Presentations;
     objPres = objPresSet.Open(strTemplate,
         MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
     objSlides = objPres.Slides;
 }