123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- using DocumentFormat.OpenXml.Drawing;
- using HTEXLib.Helpers.ShapeHelpers;
- using HTEXLib.Models.Inner;
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace HTEXLib.Models.HTEX
- {
- public class HtexSlide : HtexElement
- {
- public PPTContainerShape ContainerShape { get; set; }
- private int slideIndex;
- public HtexSlide(PPTSlide slide, int slideIndex) {
- base.slide = slide;
- //base.cssClass = slideClass;
- this.slideIndex = slideIndex;
- }
- public override List<Item> DrawElement()
- {
- List<Item> htexElements = new List<Item>();
- List<Item> items = GenerateElements();
- if (items != null) {
- htexElements.AddRange(items);
- }
- return htexElements;
- }
- private List<Item> GenerateElements()
- {
- List<Item> htexElements = null;
- if (ContainerShape.Elements.Count > 0)
- {
- htexElements = new List<Item>();
- int index = 0;
- foreach (PPTShapeBase baseShape in ContainerShape.Elements)
- {
- var a = DrawShapeHtex(baseShape, index);
- if (a != null)
- {
- htexElements.AddRange(a);
- }
-
- index++;
- }
- }
- return htexElements;
- }
- private List<Item> DrawShapeHtex( PPTShapeBase baseShape,int index)
- {
- double left = baseShape.VisualShapeProp.Left();
- double width = baseShape.VisualShapeProp.PixelWidth();
- double top = baseShape.VisualShapeProp.Top();
- double height = baseShape.VisualShapeProp.PixelHeight();
- double rot = baseShape.VisualShapeProp.Rotate;
- string Id = baseShape.NonVisualShapeProp.Id;
- bool invisible = baseShape.Invisible;
- bool animatable = baseShape.Animatable;
- string clickLinkUrl = baseShape.ClickLinkUrl;
-
- if (baseShape is PPTGraphicFrame graphicFrame)
- {
- HtexGraphicFrame htmlSmartArt = new HtexGraphicFrame(Id, rot, width, height, top,
- left, invisible, animatable ,index,graphicFrame,slide,baseShape.PartForm);
- return htmlSmartArt.DrawElement();
- }
- else if (baseShape is PPTGroupShape groupShape)
- {
- HtexGroupShape htmlShape = new HtexGroupShape(Id, rot, width, height, top,
- left, invisible, animatable,index, groupShape, slide, baseShape.PartForm);
- return htmlShape.DrawElement();
- }
- else if (baseShape is PPTConnectionShape connectionShape)
- {
- HtexConnectionShape htmlShape =
- new HtexConnectionShape(Id, rot, width, height, top,
- left, invisible, animatable,index, connectionShape, slide, baseShape.PartForm);
- return htmlShape.DrawElement();
- }
- else if (baseShape is PPTShape shape)
- {
- HtexShape htmlShape = new HtexShape(Id, rot, width, height, top,
- left, invisible, animatable, slideIndex,index, shape, slide, baseShape.PartForm)
- {
- Shape = shape,
- //rot = baseShape.VisualShapeProp.Rotate,
- HyperLink = clickLinkUrl
- };
-
- return htmlShape.DrawElement();
- }
- else if (baseShape is PPTImage image)
- {
- string imageName = baseShape.NonVisualShapeProp.Name;
- //TODO Differentiate between gif and other image types.
- //HtexImageGIF image = new HtexImageGIF(Id, _fileName, imageName,top, left);
- //slide.Append(image.DrawElement());
- HtexImage htmlImage = new HtexImage(Id, rot, width, height,
- top, left, invisible, animatable, image.FileExtension,index, image, slide, baseShape.PartForm)
- {
- HyperLink = clickLinkUrl
- };
- return htmlImage.DrawElement();
- }
- else {
- return null;
- }
- }
- public override string ToString()
- {
- Console.WriteLine("The id is:" + slide.Id);
- // Console.WriteLine("The css class is:" + cssClass);
- return slide.Id ;
- }
- }
- }
|