//Begin Presentation
    public void BeginPresentation(SocketIOEvent socketIOEvent)
    {
        CheckPowerPoint();

        if (pptApplication == null)
        {
            return;
        }

        pptApplication.Activate();
        PPt.SlideShowSettings slideShowSettings = presentation.SlideShowSettings;
        slideShowSettings.Run();
    }
Example #2
0
 public void OnWindowActivate()
 {
     if (m_ShowPaneOnActivate && !m_ManuallyHidden)
     {
         if (this.InvokeRequired)
         {
             OnWindowActivateCallback callback = new OnWindowActivateCallback(OnWindowActivate);
             this.Invoke(callback);
         }
         else
         {
             this.Show();
             m_PowerPointApplication.Activate();
         }
     }
 }
Example #3
0
        public int GetActiveSlideIndex()
        {
            var slideIndex = -1;

            try
            {
                MessageFilter.Register();
                _powerPointObject.Activate();
                var activeWindow = _powerPointObject.ActiveWindow;
                if (activeWindow != null)
                {
                    var view  = activeWindow.View;
                    var slide = (Slide)view.Slide;
                    slideIndex = slide.SlideIndex;
                    Utilities.ReleaseComObject(slide);
                    Utilities.ReleaseComObject(view);
                }
                Utilities.ReleaseComObject(activeWindow);
            }
            catch { }
            finally
            {
                MessageFilter.Revoke();
            }
            return(slideIndex);
        }
 public void Activate()
 {
     if (!HasActivePresentation())
     {
         return;
     }
     Application.Activate();
 }
Example #5
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 { }
        }
Example #6
0
 private void AppConfig()
 {
     ppt         = new PowerPoint.Application();
     ppt.Visible = MsoTriState.msoTrue;
     ppt.Activate();
     ppt.SlideShowBegin += (window) =>
     {
         Dispatcher.BeginInvoke((Action)(() =>
         {
             timeLeft = SharedResource.setting.GetLength(window.Presentation.FullName);
             label.Content = Helper.Time2Str(timeLeft);
             clock.Start();
             btnSettings.IsEnabled = false;
         }));
     };
     ppt.SlideShowEnd += (window) =>
     {
         Dispatcher.BeginInvoke((Action)(() =>
         {
             clock.Stop();
             btnSettings.IsEnabled = true;
         }));
     };
 }
Example #7
0
 //打开文件
 public void openFile(string stu, string ans, string xml)
 {
     powerpoint = new PowerPoint.ApplicationClass();
     //powerpoint.Visible = True;
     powerpoint.Activate();
     //powerpoint.Visible = False;
     //stuPpt = powerpoint.Presentations.Add(True);
     //ansPpt = powerpoint.Presentations.Add(True);
     stuPpt = powerpoint.Presentations.Open(stu, False, True, True);
     ansPpt = powerpoint.Presentations.Open(ans, False, True, True);
     oxml = new OfficeXML(xml);
     getPoint(oxml);
 }
 static PP.Application CreatePowerPointApp()
 {
     var app = new PP.Application() { Visible = O.MsoTriState.msoTrue };
     app.Activate(true);
     return app;
 }
Example #9
0
        public static string StoreMediaTemp(HttpContextBase context, HttpPostedFileBase file, UploadType type, out string thumbPath, out string physicalPath, out TimeSpan duration, out string fileType)
        {
            duration = TimeSpan.Zero;
            fileType = "";
            if (context.Session != null)
            {
                UrlFriendlyGuid GUID = (UrlFriendlyGuid)context.Session["UploadGUID"];

                List <UploadedContent> lastSavedFile = new List <UploadedContent>();

                if (context.Session["SavedFileList"] != null)
                {
                    lastSavedFile = (List <UploadedContent>)context.Session["SavedFileList"];
                }

                physicalPath = TempPathForUpload(context, file.FileName, type, GUID);
                thumbPath    = TempPathForUpload(context, file.FileName, type, GUID, true);

                //Todo: Use mimes here instead of basic extension check
                if (ImageExtensions.Contains(Path.GetExtension(file.FileName).ToLower()))
                {
                    var image = (Bitmap)Image.FromStream(file.InputStream);


                    var fullImage =
                        (Bitmap)ImageUtilities.Resize(image, image.Width, image.Height, RotateFlipType.RotateNoneFlipNone); //No need to resize
                    ImageUtilities.SaveImage(fullImage, physicalPath, ImageFormat.Jpeg, true);



                    var thumbNail =
                        (Bitmap)ImageUtilities.Resize(image, 216, 132, RotateFlipType.RotateNoneFlipNone);
                    ImageUtilities.SaveImage(thumbNail, thumbPath, ImageFormat.Jpeg, true);

                    duration = new TimeSpan(0, 0, 10);

                    fileType = "Image";
                }
                else
                {
                    var extension = Path.GetExtension(file.FileName);
                    if (extension != null && extension.ToLower() == (".txt"))
                    {
                        FileUtilities.SaveStream(file.InputStream, physicalPath, false);
                        duration = new TimeSpan(0, 0, 20);
                        var text  = new StreamReader(physicalPath).ReadToEnd();
                        var ssHot = CreateImage(text.Substring(0, text.Length > 15?15:text.Length));
                        thumbPath = thumbPath.Replace(Path.GetExtension(thumbPath), ".jpg");
                        ssHot.Save(thumbPath);

                        fileType = "Marquee";
                    }
                    else
                    {
                        var s = Path.GetExtension(file.FileName);
                        if (s != null && (s.ToLower() == (".ppt") || s.ToLower() == (".pps") || s.ToLower() == (".pptx") || s.ToLower() == (".odt"))) // Powerpoint presentation
                        {
                            string path = context.Server.MapPath("~/Logs/" + "serverlog.txt");

                            Logger.WriteLine(path, "UploadRepository:  Powerpoint");

                            FileUtilities.SaveStream(file.InputStream, physicalPath, false);

                            Logger.WriteLine(path, "UploadRepository:  Saved File @ " + physicalPath);
                            var finalPath = Path.ChangeExtension(physicalPath, "wmv");
                            Microsoft.Office.Interop.PowerPoint._Presentation objPres;
                            var objApp = new Microsoft.Office.Interop.PowerPoint.Application();

                            objApp.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
                            objApp.Activate();
                            try
                            {
                                objPres = objApp.Presentations.Open(physicalPath, MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoFalse); //Last value causes powerpoint to physically open
                                // Thread.Sleep(10000);
                                objPres.SaveAs(Path.GetFullPath(finalPath), Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsWMV);
                                Logger.WriteLine(path, "UploadRepository:  SaveCopy As Successfully Started @ " + physicalPath + " to " + finalPath);

                                long len = 0;
                                do
                                {
                                    System.Threading.Thread.Sleep(500);
                                    try
                                    {
                                        FileInfo f = new FileInfo(finalPath);
                                        len = f.Length;
                                        Logger.WriteLine(path, "UploadRepository:  SaveCopy Current Length  " + len);
                                    }
                                    catch
                                    {
                                        //continue;
                                    }
                                }while (len == 0);
                                objPres.Close();
                                objApp.Quit();

                                Marshal.ReleaseComObject(objPres);
                                Marshal.ReleaseComObject(objApp);

                                objApp  = null;
                                objPres = null;

                                GC.Collect();
                                GC.WaitForPendingFinalizers();
                                Logger.WriteLine(path, "UploadRepository:  SaveCopy Done, Creating Thumbnails  ");


                                thumbPath = thumbPath.Replace(Path.GetExtension(thumbPath), ".jpg");
                                // thumbPath = "Content\\Images\\powerpoint.jpg";
                                duration = VideoUtilities.GetVideoDuration(finalPath);
                                // duration = new TimeSpan(0, 0, 0,60);
                                VideoUtilities.GetVideoThumbnail(finalPath, thumbPath);

                                physicalPath = finalPath;
                                fileType     = "Powerpoint";
                            }
                            catch (COMException exception)
                            {
                                Logger.WriteLine(path, "UploadRepository: " + exception.StackTrace + "\n" + exception.Message + " Powerpoint fin:" + finalPath + " phys:" + physicalPath);

                                //   Logger.WriteLine(path, greenlotsInfo.email);

                                //    throw exception;
                            }
                        }
                        else // Must Be Video
                        {
                            FileUtilities.SaveStream(file.InputStream, physicalPath, false);

                            thumbPath = thumbPath.Replace(Path.GetExtension(thumbPath), ".jpg");
                            duration  = VideoUtilities.GetVideoDuration(physicalPath);

                            VideoUtilities.GetVideoThumbnail(physicalPath, thumbPath);

                            fileType = "Video";
                        }
                    }
                }

                var uploadedContent = new UploadedContent
                {
                    MediaGuid = GUID,
                    Type      = type,
                    Pictures  = new List <string>(2),
                    Duration  = duration
                };

                if (physicalPath != null)
                {
                    uploadedContent.Pictures.Add(ResolvePath(context, physicalPath));
                }
                if (thumbPath != null)
                {
                    uploadedContent.Pictures.Add(ResolvePath(context, thumbPath));
                }



                if (uploadedContent.Pictures.Count > 0)
                {
                    lastSavedFile.Add(uploadedContent);
                }


                context.Session["SavedFileList"] = lastSavedFile;


                return("Upload Sucessful");
            }
            thumbPath    = "";
            physicalPath = "";

            return("Failed To Upload File(s)");
        }
Example #10
0
        private bool BuildPowerPointFile(List <string> names)
        {
            //  open the base presentation
            // create the animations
            //  save as ... to the destination folder

            PowerPoint.Application   ppApplication   = null;
            PowerPoint.Presentations ppPresentations = null;
            PowerPoint.Presentation  ppPresentation  = null;

            try
            {
                ppApplication   = new PowerPoint.Application();
                ppPresentations = ppApplication.Presentations;

                //  to create a new presentation
                ppPresentation = ppPresentations.Add(MsoTriState.msoTrue);
                ppApplication.Activate();

                SlideWidthCentre  = (int)ppPresentation.PageSetup.SlideWidth / 2;
                SlideHeightCentre = (int)ppPresentation.PageSetup.SlideHeight / 2;

                ppPresentation.ApplyTemplate(Path.Combine(BaseSettingsFolder, TemplateFile));

                AddTitleSlide(ppPresentation, "My trust", "2015");

                AddAnimationNames(ppPresentation, names);

                //CentrePictures(ppPresentation);

                ppPresentation.SaveAs(Path.Combine(DestinationFolder, "AnimatedNames"),
                                      PowerPoint.PpSaveAsFileType.ppSaveAsDefault, MsoTriState.msoTrue);
            }
            catch (Exception e)
            {
                ProcessTextBox.AppendText(Environment.NewLine);
                ProcessTextBox.AppendText("Error: " + e.Message);

                return(false);
            }
            finally
            {
                try
                {
                    if (ppPresentation != null)
                    {
                        ppPresentation.Close();
                        ppApplication.Quit();

                        ppApplication = null;
                    }

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

                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                }
                catch (Exception e)
                {
                }
            }

            return(true);
        }
Example #11
0
    public static string StoreMediaTemp(HttpContextBase context, HttpPostedFileBase file, UploadType type, out string thumbPath, out string physicalPath, out TimeSpan duration, out string fileType)
    {
        duration = TimeSpan.Zero;
        fileType = "";
        if (context.Session != null)
        {
            UrlFriendlyGuid GUID = (UrlFriendlyGuid) context.Session["UploadGUID"];

            List<UploadedContent> lastSavedFile = new List<UploadedContent>();

            if (context.Session["SavedFileList"] != null)
                lastSavedFile = (List<UploadedContent>) context.Session["SavedFileList"];

            physicalPath = TempPathForUpload(context, file.FileName, type, GUID);
            thumbPath = TempPathForUpload(context, file.FileName, type, GUID, true);

            //Todo: Use mimes here instead of basic extension check
            if (ImageExtensions.Contains(Path.GetExtension(file.FileName).ToLower()))
            {
                var image = (Bitmap) Image.FromStream(file.InputStream);


                var fullImage =
                    (Bitmap) ImageUtilities.Resize(image, image.Width, image.Height, RotateFlipType.RotateNoneFlipNone); //No need to resize
                ImageUtilities.SaveImage(fullImage, physicalPath, ImageFormat.Jpeg, true);



                var thumbNail =
                    (Bitmap) ImageUtilities.Resize(image, 216, 132, RotateFlipType.RotateNoneFlipNone);
                ImageUtilities.SaveImage(thumbNail, thumbPath, ImageFormat.Jpeg, true);

                duration = new TimeSpan(0,0,10);

                fileType = "Image";
            }
            else
            {
                var extension = Path.GetExtension(file.FileName);
                if (extension != null && extension.ToLower()==(".txt"))
                {
                    FileUtilities.SaveStream(file.InputStream,physicalPath,false);
                    duration = new TimeSpan(0, 0, 20);
                    var text = new StreamReader(physicalPath).ReadToEnd();
                    var ssHot = CreateImage(text.Substring(0, text.Length>15?15:text.Length));
                    thumbPath = thumbPath.Replace(Path.GetExtension(thumbPath), ".jpg");
                    ssHot.Save(thumbPath);

                    fileType = "Marquee";
                }
                else
                {
                    var s = Path.GetExtension(file.FileName);
                    if (s != null && (s.ToLower() == (".ppt") || s.ToLower() == (".pps") || s.ToLower() == (".pptx") || s.ToLower() == (".odt"))) // Powerpoint presentation
                    {
                        string path = context.Server.MapPath("~/Logs/" + "serverlog.txt");

                        Logger.WriteLine(path, "UploadRepository:  Powerpoint");

                        FileUtilities.SaveStream(file.InputStream, physicalPath, false);

                        Logger.WriteLine(path, "UploadRepository:  Saved File @ " + physicalPath);
                        var finalPath = Path.ChangeExtension(physicalPath, "wmv");
                        Microsoft.Office.Interop.PowerPoint._Presentation objPres;
                        var objApp = new Microsoft.Office.Interop.PowerPoint.Application();

                        objApp.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
                        objApp.Activate();
                        try
                        {
                            objPres = objApp.Presentations.Open(physicalPath, MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoFalse); //Last value causes powerpoint to physically open
                            // Thread.Sleep(10000);
                            objPres.SaveAs(Path.GetFullPath(finalPath), Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsWMV);
                            Logger.WriteLine(path, "UploadRepository:  SaveCopy As Successfully Started @ " + physicalPath + " to "+ finalPath);
               
                            long len = 0;
                            do
                            {
                                System.Threading.Thread.Sleep(500);
                                try
                                {
                                    FileInfo f = new FileInfo(finalPath);
                                    len = f.Length;
                                    Logger.WriteLine(path, "UploadRepository:  SaveCopy Current Length  " + len);
               
                                }
                                catch
                                {
                                    //continue;
                                }
                            }
                            while (len == 0);
                            objPres.Close();
                            objApp.Quit();

                            Marshal.ReleaseComObject(objPres);
                            Marshal.ReleaseComObject(objApp);

                            objApp = null;
                            objPres = null;

                            GC.Collect();
                            GC.WaitForPendingFinalizers();
                            Logger.WriteLine(path, "UploadRepository:  SaveCopy Done, Creating Thumbnails  ");
           

                            thumbPath = thumbPath.Replace(Path.GetExtension(thumbPath), ".jpg");
                            // thumbPath = "Content\\Images\\powerpoint.jpg";
                            duration = VideoUtilities.GetVideoDuration(finalPath);
                            // duration = new TimeSpan(0, 0, 0,60);
                            VideoUtilities.GetVideoThumbnail(finalPath, thumbPath);

                            physicalPath = finalPath;
                            fileType = "Powerpoint";
                        }
                        catch (COMException exception)
                        {
              
                            Logger.WriteLine(path, "UploadRepository: " + exception.StackTrace + "\n" + exception.Message + " Powerpoint fin:" + finalPath +" phys:" +physicalPath);

                            //   Logger.WriteLine(path, greenlotsInfo.email);

                            //    throw exception;
                        }

                    }
                    else // Must Be Video
                    {
                        FileUtilities.SaveStream(file.InputStream, physicalPath, false);

                        thumbPath= thumbPath.Replace(Path.GetExtension(thumbPath), ".jpg");
                        duration = VideoUtilities.GetVideoDuration(physicalPath);

                        VideoUtilities.GetVideoThumbnail(physicalPath,thumbPath);

                        fileType = "Video";
                    }
                }
            }

            var uploadedContent = new UploadedContent
                                      {
                                          MediaGuid = GUID,
                                          Type = type,
                                          Pictures = new List<string>(2),
                                          Duration = duration
                                      };

            if (physicalPath != null)
                uploadedContent.Pictures.Add(ResolvePath(context, physicalPath));
            if (thumbPath != null)
                uploadedContent.Pictures.Add(ResolvePath(context, thumbPath));



            if (uploadedContent.Pictures.Count > 0)
                lastSavedFile.Add(uploadedContent);


            context.Session["SavedFileList"] = lastSavedFile;


            return "Upload Sucessful";
        }
        thumbPath = "";
        physicalPath = "";

        return "Failed To Upload File(s)";
    }