private static void SetTitleAndSubtitle(string presentationId, string title, string subtitle)
        {
            SlidesService slidesService = GetSlideServiceClient();

            var            slide          = GetSlides(presentationId).FirstOrDefault();
            var            titleObject    = slide.PageElements.FirstOrDefault(s => s.Shape.Placeholder.Type == "CENTERED_TITLE");
            var            subtitleObject = slide.PageElements.FirstOrDefault(s => s.Shape.Placeholder.Type == "SUBTITLE");
            List <Request> requests       = new List <Request>();
            Request        request        = new Request();

            requests.Add(ChangeText(title, titleObject));
            requests.Add(ChangeText(subtitle, subtitleObject));

            //requests.Add(request);

            // If you wish to populate the slide with elements, add create requests here,
            // using the slide ID specified above.

            // Execute the request.
            BatchUpdatePresentationRequest body =
                new BatchUpdatePresentationRequest()
            {
                Requests = requests
            };
            BatchUpdatePresentationResponse response =
                slidesService.Presentations.BatchUpdate(body, presentationId).Execute();
            //CreateSlideResponse createSlideResponse = response.Replies.First().CreateSlide;
            //Console.WriteLine("Created slide with ID: " + createSlideResponse.ObjectId);
            //return createSlideResponse.ObjectId;
        }
        private static string AddSlideToPresentation(string presentationId, string slideId)
        {
            SlidesService slidesService = GetSlideServiceClient();
            // Add a slide at index 1 using the predefined "TITLE_AND_TWO_COLUMNS" layout
            // and the ID "MyNewSlide_001".
            List <Request> requests     = new List <Request>();
            Request        request      = new Request();
            var            slideRequest = new CreateSlideRequest();

            slideRequest.ObjectId             = (slideId);
            slideRequest.InsertionIndex       = (1);
            slideRequest.SlideLayoutReference = (new LayoutReference()
            {
                PredefinedLayout = "TITLE_AND_TWO_COLUMNS"
            });

            request.CreateSlide = (slideRequest);
            requests.Add(request);

            // If you wish to populate the slide with elements, add create requests here,
            // using the slide ID specified above.

            // Execute the request.
            BatchUpdatePresentationRequest body =
                new BatchUpdatePresentationRequest()
            {
                Requests = requests
            };
            BatchUpdatePresentationResponse response =
                slidesService.Presentations.BatchUpdate(body, presentationId).Execute();
            CreateSlideResponse createSlideResponse = response.Replies.First().CreateSlide;

            Console.WriteLine("Created slide with ID: " + createSlideResponse.ObjectId);
            return(createSlideResponse.ObjectId);
        }
        private static void AddVideoToSlide(string presentationId, string slideId, string videotextTextBoxId)
        {
            SlidesService slidesService = GetSlideServiceClient();

            var slide = GetSlides(presentationId).FirstOrDefault(s => s.ObjectId == slideId);
            // Create a new square text box, using a supplied object ID.
            List <Request> requests = new List <Request>();
            Dimension      pt350    = new Dimension()
            {
                Magnitude = 350.0, Unit = "PT"
            };
            var afflineTransform = new AffineTransform()
            {
                ScaleX     = (1.0),
                ScaleY     = (1.0),
                TranslateX = (350.0),
                TranslateY = (100.0),
                Unit       = ("PT")
            };
            Size size = slide.PageElements.FirstOrDefault().Size;
            var  pageElementProperties = new PageElementProperties()
            {
                PageObjectId = slideId,
                Size         = size,
                Transform    = afflineTransform
            };

            // Insert text into the box, using the object ID given to it.
            requests.Add(new Request()
            {
                CreateVideo = new CreateVideoRequest()
                {
                    ObjectId          = videotextTextBoxId,
                    Id                = "z3iMVQlcuoE",
                    Source            = "YOUTUBE",
                    ElementProperties = pageElementProperties
                }
            });

            // Execute the requests.
            BatchUpdatePresentationRequest body =
                new BatchUpdatePresentationRequest()
            {
                Requests = requests
            };
            BatchUpdatePresentationResponse response =
                slidesService.Presentations.BatchUpdate(body, presentationId).Execute();
            CreateVideoResponse createShapeResponse = response.Replies.First().CreateVideo;

            Console.WriteLine("Created video with ID: " + createShapeResponse.ObjectId);
        }
        private static void AddVideoBackground(string presentationId, string slideId)
        {
            SlidesService slidesService = GetSlideServiceClient();
            // Add a slide at index 1 using the predefined "TITLE_AND_TWO_COLUMNS" layout
            // and the ID "MyNewSlide_001".
            List <Request> requests = new List <Request>();
            Request        request  = new Request();

            var slideRequest = new UpdatePagePropertiesRequest();

            slideRequest.ObjectId       = (slideId);
            slideRequest.Fields         = "pageBackgroundFill";
            slideRequest.PageProperties = new PageProperties()
            {
                PageBackgroundFill = new PageBackgroundFill()
                {
                    StretchedPictureFill = new StretchedPictureFill()
                    {
                        ContentUrl = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ4gPTyRGSqYQoObgXWS9JRdsqBI7sQfJfgaAwQiZR43GxrR2hjWJE-Hg"
                    }
                }
            };
            request.UpdatePageProperties = slideRequest;
            //slideRequest.InsertionIndex = (1);
            //slideRequest.SlideLayoutReference = (new LayoutReference() { PredefinedLayout = "TITLE_AND_TWO_COLUMNS" });
            //request.UpdateShapeProperties = new UpdateShapePropertiesRequest()
            //    slideRequest.UpdatePageProperties = new UpdatePagePropertiesRequest() {Fields= "pageBackgroundFill" , PageProperties = new PageProperties() { PageBackgroundFill = new PageBackgroundFill() { StretchedPictureFill = new StretchedPictureFill() { ContentUrl = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ4gPTyRGSqYQoObgXWS9JRdsqBI7sQfJfgaAwQiZR43GxrR2hjWJE-Hg" } } } };
            requests.Add(request);

            // If you wish to populate the slide with elements, add create requests here,
            // using the slide ID specified above.

            // Execute the request.
            BatchUpdatePresentationRequest body =
                new BatchUpdatePresentationRequest()
            {
                Requests = requests
            };
            BatchUpdatePresentationResponse response =
                slidesService.Presentations.BatchUpdate(body, presentationId).Execute();
        }
        private static void AddTextToSlide(string presentationId, string slideId, String textBoxId)
        {
            SlidesService slidesService = GetSlideServiceClient();
            // Create a new square text box, using a supplied object ID.
            List <Request> requests = new List <Request>();
            Dimension      pt350    = new Dimension()
            {
                Magnitude = 350.0, Unit = "PT"
            };
            var afflineTransform = new AffineTransform()
            {
                ScaleX     = (1.0),
                ScaleY     = (1.0),
                TranslateX = (350.0),
                TranslateY = (100.0),
                Unit       = ("PT")
            };
            Size size = new Size()
            {
                Height = (pt350),
                Width  = (pt350)
            };
            var pageElementProperties = new PageElementProperties()
            {
                PageObjectId = slideId,
                Size         = size,
                Transform    = afflineTransform
            };

            requests.Add(new Request()
            {
                CreateShape = new CreateShapeRequest()
                {
                    ObjectId          = (textBoxId),
                    ShapeType         = ("TEXT_BOX"),
                    ElementProperties = pageElementProperties
                }
            });

            // Insert text into the box, using the object ID given to it.
            requests.Add(new Request()
            {
                InsertText = (new InsertTextRequest()
                {
                    ObjectId = (textBoxId),
                    InsertionIndex = (0),
                    Text = ("New Box Text Inserted")
                })
            });

            // Execute the requests.
            BatchUpdatePresentationRequest body =
                new BatchUpdatePresentationRequest()
            {
                Requests = requests
            };
            BatchUpdatePresentationResponse response =
                slidesService.Presentations.BatchUpdate(body, presentationId).Execute();
            CreateShapeResponse createShapeResponse = response.Replies.First().CreateShape;

            Console.WriteLine("Created textbox with ID: " + createShapeResponse.ObjectId);
        }
        private static void AddImageToSlide(string presentationId, string slideId, string textBoxId)
        {
            SlidesService slidesService = GetSlideServiceClient();
            // Create a new square text box, using a supplied object ID.
            List <Request> requests = new List <Request>();
            Dimension      pt350    = new Dimension()
            {
                Magnitude = 350.0, Unit = "PT"
            };
            var afflineTransform = new AffineTransform()
            {
                ScaleX     = (1.0),
                ScaleY     = (1.0),
                TranslateX = (350.0),
                TranslateY = (100.0),
                Unit       = ("PT")
            };
            Size size = new Size()
            {
                Height = (pt350),
                Width  = (pt350)
            };
            var pageElementProperties = new PageElementProperties()
            {
                PageObjectId = slideId,
                Size         = size,
                Transform    = afflineTransform
            };

            //requests.Add(new Request()
            //{
            //    CreateShape = new CreateShapeRequest()
            //    {
            //        ObjectId = textBoxId,
            //        ShapeType = "TEXT_BOX",
            //        ElementProperties = pageElementProperties
            //    }
            //});

            // Insert text into the box, using the object ID given to it.
            requests.Add(new Request()
            {
                CreateImage = new CreateImageRequest()
                {
                    ObjectId          = textBoxId,
                    Url               = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ4gPTyRGSqYQoObgXWS9JRdsqBI7sQfJfgaAwQiZR43GxrR2hjWJE-Hg",
                    ElementProperties = pageElementProperties
                }
            });

            // Execute the requests.
            BatchUpdatePresentationRequest body =
                new BatchUpdatePresentationRequest()
            {
                Requests = requests
            };
            BatchUpdatePresentationResponse response =
                slidesService.Presentations.BatchUpdate(body, presentationId).Execute();
            CreateImageResponse createShapeResponse = response.Replies.First().CreateImage;

            Console.WriteLine("Created textbox with ID: " + createShapeResponse.ObjectId);
        }