leonreucher / powerpoint-remote-websocket

VSTO PowerPoint plugin to remote control the SlideShow using a WebSocket connection
6 stars 1 forks source link

Autostart presentation after opening #6

Open meitzner-hannes opened 3 weeks ago

meitzner-hannes commented 3 weeks ago

regarding #4 and #5

could you add a parameter to the openPresentation function to autostart a presentation after opening it?

It would be handy to have it to quickly open and start a presentation with just one function.

the code could be like this: (I added a part of #5 into it)

public void OpenPresentation(string path, bool closeOthers, bool forceActive, bool autostart)
    {
        bool isLoaded = false;

        if(closeOthers)
        {
            this.CloseAllPresentations();
        }

        /// check if presentation is already loaded
        if (path is in the array of open presentations paths)
        {
            isLoaded = true;
        }

        if (isLoaded == true)
        {
             /// set it active

        } 
        elseif (isLoaded == false)
        {

            try
            {
                Application.Presentations.Open(@path);

                /// wait for loading completion
                bool isLoaded = true;
            }
            catch(FileNotFoundException e)
            {
                this.SendWebSocketMessage("File not found");
            }

            if (isLoaded == true and autostart == true)
            {

                Presentation presentation = Application.ActivePresentation;
                presentation.SlideShowSettings.Run();
            }
        }
    }

`this is only a ruff mockup and not very refined, just to get an idea...