private static IPListElement ExportText(Omnigraffle.ShapedGraphic graphic) { var dict = new PListDict(); var alignement = @"\ql"; if (graphic.Text.Alignement == Omnigraffle.TextAlignement.Center) { alignement = @"\qc"; } else if (graphic.Text.Alignement == Omnigraffle.TextAlignement.Right) { alignement = @"\qr"; } else if (graphic.Text.Alignement == Omnigraffle.TextAlignement.Justified) { alignement = @"\qj"; } dict.Add("Text", new PListString(string.Format(@"{{\rtf1\ansi\ansicpg1252\cocoartf1138\cocoasubrtf470 {{\fonttbl\f0\fswiss\fcharset0 {1};}} {{\colortbl;\red255\green255\blue255;}} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural{3} \f0\fs{2} \cf0 {0}}}", graphic.Text.Text, graphic.FontInfo.Font, graphic.FontInfo.Size * 2, alignement))); // if (graphic.Text.SideMargin > 0) dict.Add("Pad", new PListInteger(graphic.Text.SideMargin)); // if (graphic.Text.TopBottomMargin > 0) dict.Add("VerticalPad", new PListInteger(graphic.Text.TopBottomMargin)); return(dict); }
protected ShapedGraphic GetHexagon() { var graphic = new Omnigraffle.ShapedGraphic(NextId, Omnigraffle.Shape.Bezier, 50, 50, 150, 70); graphic.ShapeData.UnitPoints.Add(new KAOSTools.OmnigraffleExport.Omnigraffle.Point(-0.45, -0.5)); graphic.ShapeData.UnitPoints.Add(new KAOSTools.OmnigraffleExport.Omnigraffle.Point(-0.45, -0.5)); graphic.ShapeData.UnitPoints.Add(new KAOSTools.OmnigraffleExport.Omnigraffle.Point(0.45, -0.5)); graphic.ShapeData.UnitPoints.Add(new KAOSTools.OmnigraffleExport.Omnigraffle.Point(0.45, -0.5)); graphic.ShapeData.UnitPoints.Add(new KAOSTools.OmnigraffleExport.Omnigraffle.Point(0.45, -0.5)); graphic.ShapeData.UnitPoints.Add(new KAOSTools.OmnigraffleExport.Omnigraffle.Point(0.5, 0)); graphic.ShapeData.UnitPoints.Add(new KAOSTools.OmnigraffleExport.Omnigraffle.Point(0.5, 0)); graphic.ShapeData.UnitPoints.Add(new KAOSTools.OmnigraffleExport.Omnigraffle.Point(0.5, 0)); graphic.ShapeData.UnitPoints.Add(new KAOSTools.OmnigraffleExport.Omnigraffle.Point(0.45, 0.5)); graphic.ShapeData.UnitPoints.Add(new KAOSTools.OmnigraffleExport.Omnigraffle.Point(0.45, 0.5)); graphic.ShapeData.UnitPoints.Add(new KAOSTools.OmnigraffleExport.Omnigraffle.Point(0.45, 0.5)); graphic.ShapeData.UnitPoints.Add(new KAOSTools.OmnigraffleExport.Omnigraffle.Point(-0.45, 0.5)); graphic.ShapeData.UnitPoints.Add(new KAOSTools.OmnigraffleExport.Omnigraffle.Point(-0.45, 0.5)); graphic.ShapeData.UnitPoints.Add(new KAOSTools.OmnigraffleExport.Omnigraffle.Point(-0.45, 0.5)); graphic.ShapeData.UnitPoints.Add(new KAOSTools.OmnigraffleExport.Omnigraffle.Point(-0.5, 0)); graphic.ShapeData.UnitPoints.Add(new KAOSTools.OmnigraffleExport.Omnigraffle.Point(-0.5, 0)); graphic.ShapeData.UnitPoints.Add(new KAOSTools.OmnigraffleExport.Omnigraffle.Point(-0.5, 0)); graphic.ShapeData.UnitPoints.Add(new KAOSTools.OmnigraffleExport.Omnigraffle.Point(-0.45, -0.5)); return(graphic); }
protected void AddText(LineGraphic graphic, string text, float position = 0.5f) { var labelBox = new Omnigraffle.ShapedGraphic(NextId, Omnigraffle.Shape.Rectangle, 50, 50, 100, 100); labelBox.Text = new Omnigraffle.TextInfo(text) { Alignement = KAOSTools.OmnigraffleExport.Omnigraffle.TextAlignement.Center, SideMargin = 0, TopBottomMargin = 0 }; labelBox.FontInfo.Size = 8; labelBox.Style.Shadow.Draws = false; labelBox.FitText = KAOSTools.OmnigraffleExport.Omnigraffle.FitText.Yes; // labelBox.Wrap = false; labelBox.Flow = KAOSTools.OmnigraffleExport.Omnigraffle.Flow.Resize; labelBox.Style.Fill.Color = new KAOSTools.OmnigraffleExport.Omnigraffle.Color(1, 1, 1); labelBox.Style.Stroke.Draws = false; labelBox.Line = new LineInfo(graphic.ID) { Position = position }; sheet.GraphicsList.Add(labelBox); }
private static IPListElement ExportShapedGraphic(Omnigraffle.ShapedGraphic graphic) { var dict = new PListDict(); dict.Add("Bounds", ExportBounds(graphic.Bounds)); dict.Add("Class", new PListString(graphic.Class)); dict.Add("ID", new PListInteger(graphic.ID)); var shape = new PListString(); if (graphic.Shape == Omnigraffle.Shape.Bezier) { shape.Value = "Bezier"; } else if (graphic.Shape == Omnigraffle.Shape.Rectangle) { shape.Value = "Rectangle"; } else if (graphic.Shape == Omnigraffle.Shape.Circle) { shape.Value = "Circle"; } else if (graphic.Shape == Omnigraffle.Shape.Cloud) { shape.Value = "Cloud"; } else { throw new NotImplementedException(); } dict.Add("Shape", shape); var fit_text = new PListString(); if (graphic.FitText == Omnigraffle.FitText.Vertical) { fit_text.Value = "Vertical"; } if (graphic.FitText == Omnigraffle.FitText.Clip) { fit_text.Value = "Clip"; } if (graphic.FitText == Omnigraffle.FitText.Yes) { fit_text.Value = "Clip"; } dict.Add("FitText", fit_text); var flow = new PListString(); if (graphic.Flow == Omnigraffle.Flow.Resize) { flow.Value = "Resize"; } if (graphic.Flow == Omnigraffle.Flow.Clip) { flow.Value = "Clip"; } dict.Add("Flow", flow); var wrap = new PListString(); if (!graphic.Wrap) { wrap.Value = "NO"; dict.Add("Wrap", wrap); } if (graphic.FontInfo != default(Omnigraffle.FontInfo)) { dict.Add("Font", ExportFont(graphic.FontInfo)); } if (graphic.ShapeData != default(Omnigraffle.ShapeData)) { dict.Add("ShapeData", ExportShapeData(graphic.ShapeData)); } if (graphic.Style != default(Omnigraffle.StyleInfo)) { dict.Add("Style", ExportStyle(graphic.Style)); } if (graphic.VFlip) { dict.Add("VFlip", new PListBool(graphic.VFlip)); } if (graphic.HFlip) { dict.Add("HFlip", new PListBool(graphic.HFlip)); } if (!graphic.AllowConnections) { dict.Add("AllowConnections", new PListString(graphic.AllowConnections ? "YES" : "NO")); } if (graphic.Text != default(Omnigraffle.TextInfo)) { dict.Add("Text", ExportText(graphic)); } if (graphic.Line != null) { var d2 = new PListDict(); d2.Add("ID", new PListInteger(graphic.Line.ID)); d2.Add("Position", new PListReal(graphic.Line.Position)); d2.Add("RotationType", new PListInteger(graphic.Line.RotationType == Omnigraffle.RotationType.Default ? 0 : 0)); dict.Add("Line", d2); } if (graphic.Magnets.Count > 0) { var d2 = new PListArray(); foreach (var m in graphic.Magnets) { d2.Add(new PListString(string.Format("{{{0},{1}}}", m.X, m.Y))); } dict.Add("Magnets", d2); } return(dict); }