Beispiel #1
0
 public Shape(PowerPoint.Shape shape, string shapeIdTagName, string slideIdTagName)
 {
     this.shape          = shape;
     this.shapeIdTagName = shapeIdTagName;
     this.slideIdTagName = slideIdTagName;
     if (this.shape.HasTextFrame == MsoTriState.msoTrue)
     {
         this.font = new Font(this.shape.TextFrame2.TextRange.Font);
     }
 }
Beispiel #2
0
        public void RunExample()
        {
            bool   isFailed     = false;
            string documentFile = null;

            PowerPoint.Application powerApplication = null;
            try
            {
                // start powerpoint
                powerApplication = COMObject.Create <PowerPoint.Application>();

                // create a utils instance, no need for but helpful to keep the lines of code low
                CommonUtils utils = new CommonUtils(powerApplication);

                // add a new presentation with one new slide
                PowerPoint.Presentation presentation = powerApplication.Presentations.Add(MsoTriState.msoTrue);
                PowerPoint.Slide        slide        = presentation.Slides.Add(1, PpSlideLayout.ppLayoutBlank);

                // add new module and insert macro. the option "Trust access to Visual Basic Project" must be set
                VB.CodeModule module = presentation.VBProject.VBComponents.Add(vbext_ComponentType.vbext_ct_StdModule).CodeModule;
                string        macro  = string.Format("Sub NetOfficeTestMacro()\r\n   {0}\r\nEnd Sub", "MsgBox \"Thanks for click!\"");
                module.InsertLines(1, macro);

                // add button and connect with macro
                PowerPoint.Shape button = slide.Shapes.AddShape(MsoAutoShapeType.msoShapeActionButtonForwardorNext, 100, 100, 200, 200);
                button.ActionSettings[PpMouseActivation.ppMouseClick].AnimateAction = MsoTriState.msoTrue;
                button.ActionSettings[PpMouseActivation.ppMouseClick].Action        = PpActionType.ppActionRunMacro;
                button.ActionSettings[PpMouseActivation.ppMouseClick].Run           = "NetOfficeTestMacro";

                // save the document
                documentFile = utils.File.Combine(HostApplication.RootDirectory, "Example03", DocumentFormat.Macros);
                presentation.SaveAs(documentFile);
            }
            catch (System.Runtime.InteropServices.COMException throwedException)
            {
                isFailed = true;
                HostApplication.ShowErrorDialog("VBA Error", throwedException);
            }
            finally
            {
                // close power point and dispose reference
                if (powerApplication != null)
                {
                    powerApplication.Quit();
                    powerApplication.Dispose();
                }

                if ((null != documentFile) && (!isFailed))
                {
                    HostApplication.ShowFinishDialog(null, documentFile);
                }
            }
        }
Beispiel #3
0
 private static void DrowItemText(Slide newSlide, string text)
 {
     PowerPoint.Shape label = newSlide.Shapes[1];
     label.Left   = 20;
     label.Top    = 20;
     label.Width  = 750;
     label.Height = 20;
     label.TextFrame.TextRange.Font.Size = 12;
     label.TextFrame.TextRange.Font.Bold = MsoTriState.msoTrue;
     label.TextFrame.TextRange.Text      = text;
     label.TextFrame.TextRange.ParagraphFormat.Alignment = PpParagraphAlignment.ppAlignCenter;
 }
Beispiel #4
0
 private static void DrowHyperlinkText(Slide newSlide, Uri uri)
 {
     PowerPoint.Shape label = newSlide.Shapes.AddLabel(MsoTextOrientation.msoTextOrientationHorizontal, 20, 500, 750, 20);
     label.Left  = 20;
     label.Width = 750;
     label.TextFrame.TextRange.Font.Size              = 12;
     label.TextFrame.TextRange.Font.Italic            = MsoTriState.msoTrue;
     label.TextFrame.TextRange.Font.Color.SchemeColor = PpColorSchemeIndex.ppAccent2;// .RGB = System.Drawing.Color.FromArgb(100, 51, 102, 187).ToArgb();
     label.TextFrame.TextRange.Text = uri.ToString();
     label.TextFrame.TextRange.ParagraphFormat.Alignment                    = PpParagraphAlignment.ppAlignCenter;
     label.ActionSettings[PpMouseActivation.ppMouseClick].Action            = PpActionType.ppActionHyperlink;
     label.ActionSettings[PpMouseActivation.ppMouseClick].Hyperlink.Address = uri.ToString();
 }
Beispiel #5
0
        public TestResult DoTest()
        {
            PowerPoint.Application application = null;
            DateTime startTime = DateTime.Now;

            try
            {
                application = COMObject.Create <PowerPoint.Application>(COMObjectCreateOptions.CreateNewCore);

                // add a new presentation with one new slide
                PowerPoint.Presentation presentation = application.Presentations.Add(MsoTriState.msoTrue);
                PowerPoint.Slide        slide        = presentation.Slides.Add(1, PpSlideLayout.ppLayoutBlank);

                // add a label
                PowerPoint.Shape label = slide.Shapes.AddLabel(MsoTextOrientation.msoTextOrientationHorizontal, 10, 10, 600, 20);
                label.TextFrame.TextRange.Text = "This slide and created Shapes are created by NetOffice example.";

                // add a line
                slide.Shapes.AddLine(10, 80, 700, 80);

                // add a wordart
                slide.Shapes.AddTextEffect(MsoPresetTextEffect.msoTextEffect9, "This a WordArt", "Arial", 20,
                                           MsoTriState.msoTrue, MsoTriState.msoFalse, 10, 150);

                // add a star
                slide.Shapes.AddShape(MsoAutoShapeType.msoShape24pointStar, 200, 200, 250, 250);

                return(new TestResult(true, DateTime.Now.Subtract(startTime), "", null, ""));
            }
            catch (Exception exception)
            {
                return(new TestResult(false, DateTime.Now.Subtract(startTime), exception.Message, exception, ""));
            }
            finally
            {
                if (null != application)
                {
                    application.Quit();
                    application.Dispose();
                }
            }
        }
 public Paragraph(PowerPoint.Shape shape, Dictionary<string, object> parameters)
 {
     this.shape = shape;
     object tmp;
     if (parameters.TryGetValue("start", out tmp))
     {
         this.start = (int)tmp;
     }
     else
     {
         this.start = -1;
     }
     if (parameters.TryGetValue("length", out tmp))
     {
         this.length = (int)tmp;
     }
     else
     {
         this.length = -1;
     }
 }
        public Paragraph(PowerPoint.Shape shape, Dictionary <string, object> parameters)
        {
            this.shape = shape;
            object tmp;

            if (parameters.TryGetValue("start", out tmp))
            {
                this.start = (int)tmp;
            }
            else
            {
                this.start = -1;
            }
            if (parameters.TryGetValue("length", out tmp))
            {
                this.length = (int)tmp;
            }
            else
            {
                this.length = -1;
            }
        }
Beispiel #8
0
        public void RunExample()
        {
            // start powerpoint
            PowerPoint.Application powerApplication = new PowerPoint.Application();

            // create a utils instance, no need for but helpful to keep the lines of code low
            CommonUtils utils = new CommonUtils(powerApplication);

            // add a new presentation with one new slide
            PowerPoint.Presentation presentation = powerApplication.Presentations.Add(MsoTriState.msoTrue);
            PowerPoint.Slide        slide        = presentation.Slides.Add(1, PpSlideLayout.ppLayoutBlank);

            // add a label
            PowerPoint.Shape label = slide.Shapes.AddLabel(MsoTextOrientation.msoTextOrientationHorizontal, 10, 10, 600, 20);
            label.TextFrame.TextRange.Text = "This slide and created Shapes are created by NetOffice example.";

            // add a line
            slide.Shapes.AddLine(10, 80, 700, 80);

            // add a wordart
            slide.Shapes.AddTextEffect(MsoPresetTextEffect.msoTextEffect9, "This a WordArt", "Arial", 20,
                                       MsoTriState.msoTrue, MsoTriState.msoFalse, 10, 150);

            // add a star
            slide.Shapes.AddShape(MsoAutoShapeType.msoShape24pointStar, 200, 200, 250, 250);

            // save the document
            string documentFile = utils.File.Combine(HostApplication.RootDirectory, "Example02", DocumentFormat.Normal);

            presentation.SaveAs(documentFile);

            // close power point and dispose reference
            powerApplication.Quit();
            powerApplication.Dispose();

            // show end dialog
            HostApplication.ShowFinishDialog(null, documentFile);
        }
Beispiel #9
0
        public void RunExample()
        {
            // start powerpoint
            PowerPoint.Application powerApplication = new PowerPoint.Application();

            // add a new presentation with one new slide
            PowerPoint.Presentation presentation = powerApplication.Presentations.Add(MsoTriState.msoTrue);
            PowerPoint.Slide        slide        = presentation.Slides.Add(1, PpSlideLayout.ppLayoutBlank);

            // add a label
            PowerPoint.Shape label = slide.Shapes.AddLabel(MsoTextOrientation.msoTextOrientationHorizontal, 10, 10, 600, 20);
            label.TextFrame.TextRange.Text = "This slide and created Shapes are created by NetOffice example.";

            // add a line
            slide.Shapes.AddLine(10, 80, 700, 80);

            // add a wordart
            slide.Shapes.AddTextEffect(MsoPresetTextEffect.msoTextEffect9, "This a WordArt", "Arial", 20,
                                       MsoTriState.msoTrue, MsoTriState.msoFalse, 10, 150);

            // add a star
            slide.Shapes.AddShape(MsoAutoShapeType.msoShape24pointStar, 200, 200, 250, 250);

            // save the document
            string fileExtension = GetDefaultExtension(powerApplication);
            string documentFile  = string.Format("{0}\\Example02{1}", _hostApplication.RootDirectory, fileExtension);

            presentation.SaveAs(documentFile);

            // close power point and dispose reference
            powerApplication.Quit();
            powerApplication.Dispose();

            // show dialog for the user(you!)
            _hostApplication.ShowFinishDialog(null, documentFile);
        }
Beispiel #10
0
 public PowerPointTags(PowerPoint.Shape shape)
 {
     this.element = shape;
 }
Beispiel #11
0
 public Paragraph(PowerPoint.Shape shape, int start, int length)
 {
     this.shape  = shape;
     this.start  = start;
     this.length = length;
 }
Beispiel #12
0
 public NetOffice.PowerPointApi.Effect AddTriggerEffect(NetOffice.PowerPointApi.Shape pShape, NetOffice.PowerPointApi.Enums.MsoAnimEffect effectId, NetOffice.PowerPointApi.Enums.MsoAnimTriggerType trigger, NetOffice.PowerPointApi.Shape pTriggerShape, object bookmark)
 {
     return(InvokerService.InvokeInternal.ExecuteKnownReferenceMethodGet <NetOffice.PowerPointApi.Effect>(this, "AddTriggerEffect", typeof(NetOffice.PowerPointApi.Effect), new object[] { pShape, effectId, trigger, pTriggerShape, bookmark }));
 }
Beispiel #13
0
 public NetOffice.PowerPointApi.Effect FindFirstAnimationFor(NetOffice.PowerPointApi.Shape shape)
 {
     return(InvokerService.InvokeInternal.ExecuteKnownReferenceMethodGet <NetOffice.PowerPointApi.Effect>(this, "FindFirstAnimationFor", typeof(NetOffice.PowerPointApi.Effect), shape));
 }
Beispiel #14
0
 public NetOffice.PowerPointApi.Effect AddEffect(NetOffice.PowerPointApi.Shape shape, NetOffice.PowerPointApi.Enums.MsoAnimEffect effectId, object level, object trigger)
 {
     return(InvokerService.InvokeInternal.ExecuteKnownReferenceMethodGet <NetOffice.PowerPointApi.Effect>(this, "AddEffect", typeof(NetOffice.PowerPointApi.Effect), shape, effectId, level, trigger));
 }
Beispiel #15
0
 public Character(PowerPoint.Shape shape, int start, int length)
 {
     this.character = shape.TextFrame2.TextRange.Characters(start, length);
     this.font      = new Font(this.character.Font);
 }
Beispiel #16
0
 public Shape(PowerPoint.Shape shape)
 {
     this.shape = shape;
     this.tags  = new PowerPointTags(this.shape);
 }
Beispiel #17
0
 public Shape(PowerPoint.Shape shape)
 {
     this.shape = shape;
     this.tags = new PowerPointTags(this.shape);
 }
Beispiel #18
0
 public void EndConnect(NetOffice.PowerPointApi.Shape connectedShape, Int32 connectionSite)
 {
     InvokerService.InvokeInternal.ExecuteMethod(this, "EndConnect", connectedShape, connectionSite);
 }