示例#1
0
        public void AddOrUpdateTextShape(SlideItemType type, String text, int loopOid, PowerPoint.Shape shape = null)
        {
            PowerPoint.Slide activeSlide = (PowerPoint.Slide)GetActiveSlide();
            if (activeSlide == null)
            {
                return;
            }
            if (shape == null)
            {
                shape = GetActiveShape();
            }
            String value = type == SlideItemType.INCREMENTAL ? text : "" + loopOid;
            bool   added = false;

            if (shape == null)
            {
                shapeShiftPosition += 5F;
                float left = 15F + shapeShiftPosition + 2F;
                float top  = 25F + shapeShiftPosition + 5F;
                shape = activeSlide.Shapes.AddShape(MsoAutoShapeType.msoShapeRectangle, left, top, 150F, 50F);
                added = true;
            }
            try
            {
                PowerPoint.TextRange range = shape.TextFrame.TextRange;
                range.Text = text;
                if (added && ShapeAdded != null)
                {
                    ShapeAdded(activeSlide.SlideNumber, activeSlide.Name, shape.Id, value, type, text);
                }
                if (!added && ShapeUpdated != null)
                {
                    ShapeUpdated(activeSlide.SlideNumber, activeSlide.Name, shape.Id, value, type, text);
                }
            }
            catch (Exception)  {
                shapeShiftPosition += 5F;
                float left = 15F + shapeShiftPosition + 2F;
                float top  = 25F + shapeShiftPosition + 5F;
                shape = activeSlide.Shapes.AddShape(MsoAutoShapeType.msoShapeRectangle, left, top, 150F, 50F);
                if (ShapeAdded != null)
                {
                    ShapeAdded(activeSlide.SlideNumber, activeSlide.Name, shape.Id, value, type, text);
                }
            }
        }
示例#2
0
        private void OnShapeChanged(int slidePosition, String slideName, int shapePosition, String shapeValue, SlideItemType type, String shapeName)
        {
            PresentationEditorItem page = (PresentationEditorItem)getPresentationEditor().getActivePage();

            if (page == null)
            {
                return;
            }
            bool added = false;
            PresentationSlide presentationSlide = page.EditedObject.getSlide(slidePosition);

            if (presentationSlide == null)
            {
                presentationSlide = new PresentationSlide(slidePosition, slideName);
                added             = true;
            }

            if (added)
            {
                page.EditedObject.AddSlide(presentationSlide);
            }
            else
            {
                page.EditedObject.UpdateSlide(presentationSlide);
            }

            PresentationSlideItem item = presentationSlide.getShape(shapePosition);

            added = false;
            if (item == null)
            {
                item  = new PresentationSlideItem();
                added = true;
            }
            item.index = shapePosition;
            item.value = shapeValue;
            item.type  = type;
            item.name  = shapeName;
            if (added)
            {
                presentationSlide.AddShape(item);
            }
            else
            {
                presentationSlide.UpdateShape(item);
            }

            Change();
        }
示例#3
0
        private void OnShapeDeleted(int slidePosition, String slideName, int shapePosition, String shapeValue, SlideItemType type, String shapeName)
        {
            PresentationEditorItem page = (PresentationEditorItem)getPresentationEditor().getActivePage();

            if (page == null)
            {
                return;
            }
            PresentationSlide presentationSlide = page.EditedObject.getSlide(slidePosition);

            if (presentationSlide == null)
            {
                return;
            }
            PresentationSlideItem item = presentationSlide.getShape(shapePosition);

            if (item == null)
            {
                return;
            }
            presentationSlide.DeleteShape(item);
            page.EditedObject.UpdateSlide(presentationSlide);
            Change();
        }