public void OpenXmlSimpleTypeConverterTest() { // 1. Base64BinaryValue Base64BinaryValue base64 = new Base64BinaryValue(); base64 = "AA3322"; Assert.True("AA3322" == base64); Assert.Equal("AA3322", base64.Value); base64 = Base64BinaryValue.FromString("1234"); Assert.Equal("1234", base64.ToString()); Assert.Equal("1234", Base64BinaryValue.ToString(base64)); // 2. BooleanValue BooleanValue booleanValue = new BooleanValue(); booleanValue = true; Assert.True(booleanValue); Assert.True(booleanValue.Value); booleanValue = BooleanValue.FromBoolean(false); Assert.False(booleanValue); Assert.Equal(false, BooleanValue.ToBoolean(booleanValue)); // 3. ByteValue ByteValue byteValue = new ByteValue(); Byte bt = 1; byteValue = bt; Assert.True(bt == byteValue); Assert.Equal(bt, byteValue.Value); bt = 2; byteValue = ByteValue.FromByte(bt); Assert.Equal(bt, ByteValue.ToByte(byteValue)); // 4. DateTimeValue DateTimeValue dtValue = new DateTimeValue(); DateTime dt = DateTime.Now; dtValue = dt; Assert.True(dt == dtValue); dt = DateTime.Now.AddDays(1); dtValue = DateTimeValue.FromDateTime(dt); Assert.Equal(dt, dtValue.Value); Assert.Equal(dt, DateTimeValue.ToDateTime(dt)); // 5. DecimalValue DecimalValue decimalValue = new DecimalValue(); decimal dcm = 10; decimalValue = dcm; Assert.True(dcm == decimalValue); decimalValue = DecimalValue.FromDecimal(20); Assert.Equal(20, decimalValue.Value); Assert.Equal(20, DecimalValue.ToDecimal(decimalValue)); // 6. DoubleValue DoubleValue doubleValue = new DoubleValue(); double dbl = 1.1; doubleValue = dbl; Assert.True(dbl == doubleValue); doubleValue = DoubleValue.FromDouble(2.2); Assert.Equal(2.2, doubleValue.Value); Assert.Equal(2.2, DoubleValue.ToDouble(doubleValue)); // 7. HexBinaryValue HexBinaryValue hexBinaryValue = new HexBinaryValue(); string hex = "0X99CCFF"; hexBinaryValue = hex; Assert.True(hex == hexBinaryValue); hex = "111111"; hexBinaryValue = HexBinaryValue.FromString(hex); Assert.Equal(hex, hexBinaryValue.Value); Assert.Equal(hex, HexBinaryValue.ToString(hexBinaryValue)); // 8. Int16 Int16Value int16Value = new Int16Value(); Int16 int16 = 16; int16Value = int16; Assert.True(int16 == int16Value); int16 = 17; int16Value = Int16Value.FromInt16(int16); Assert.Equal(int16, int16Value.Value); Assert.Equal(int16, Int16Value.ToInt16(int16Value)); // 9. Int32 Int32Value int32Value = new Int32Value(); Int32 int32 = 32; int32Value = int32; Assert.True(int32 == int32Value); int32 = 33; int32Value = Int32Value.FromInt32(int32); Assert.Equal(int32, int32Value.Value); Assert.Equal(int32, Int32Value.ToInt32(int32Value)); // 10. Int64 Int64Value int64Value = new Int64Value(); Int64 int64 = 64; int64Value = int64; Assert.True(int64 == int64Value); int64 = 17; int64Value = Int64Value.FromInt64(int64); Assert.Equal(int64, int64Value.Value); Assert.Equal(int64, Int64Value.ToInt64(int64Value)); // 11. IntegerValue IntegerValue integerValue = new IntegerValue(); int integer = 64; integerValue = integer; Assert.True(integer == integerValue); integer = 17; integerValue = IntegerValue.FromInt64(integer); Assert.Equal(integer, integerValue.Value); Assert.Equal(integer, IntegerValue.ToInt64(integerValue)); // 12. OnOffValue OnOffValue onOffValue = new OnOffValue(); onOffValue = true; Assert.True(onOffValue); onOffValue = OnOffValue.FromBoolean(false); Assert.Equal(false, onOffValue.Value); Assert.Equal(false, OnOffValue.ToBoolean(onOffValue)); // 13. SByteValue SByteValue sbyteValue = new SByteValue(); SByte sbt = SByte.MaxValue; sbyteValue = sbt; Assert.True(sbt == sbyteValue); sbt = SByte.MinValue; sbyteValue = SByteValue.FromSByte(sbt); Assert.Equal(sbt, sbyteValue.Value); Assert.Equal(sbt, SByteValue.ToSByte(sbt)); // 14. SingleValue SingleValue singleValue = new SingleValue(); Single single = Single.MaxValue; singleValue = single; Assert.True(single == singleValue); single = Single.NaN; singleValue = SingleValue.FromSingle(single); Assert.Equal(single, singleValue.Value); Assert.Equal(single, SingleValue.ToSingle(singleValue)); // 15. StringValue StringValue stringValue = new StringValue(); String str = "Ethan"; stringValue = str; Assert.True(str == stringValue); str = "Yin"; stringValue = StringValue.FromString(str); Assert.Equal(str, stringValue.Value); Assert.Equal(str, stringValue.ToString()); Assert.Equal(str, StringValue.ToString(stringValue)); // 16. TrueFalseBlankValue TrueFalseBlankValue tfbValue = new TrueFalseBlankValue(); tfbValue = true; Assert.True(tfbValue); tfbValue = TrueFalseBlankValue.FromBoolean(false); Assert.Equal(false, tfbValue.Value); Assert.Equal(false, TrueFalseBlankValue.ToBoolean(tfbValue)); // 17. TrueFalseValue TrueFalseValue tfValue = new TrueFalseValue(); tfValue = true; Assert.True(tfValue); tfValue = TrueFalseValue.FromBoolean(false); Assert.Equal(false, tfValue.Value); Assert.Equal(false, TrueFalseValue.ToBoolean(tfValue)); // 18. UInt16Value UInt16Value uint16Value = new UInt16Value(); UInt16 uint16 = UInt16.MaxValue; uint16Value = uint16; Assert.True(uint16 == uint16Value); uint16 = UInt16.MinValue; uint16Value = UInt16Value.FromUInt16(uint16); Assert.Equal(uint16, uint16Value.Value); Assert.Equal(uint16, UInt16Value.ToUInt16(uint16Value)); // 19. UInt32Value UInt32Value uint32Value = new UInt32Value(); UInt32 uint32 = UInt32.MaxValue; uint32Value = uint32; Assert.True(uint32 == uint32Value); uint32 = UInt32.MinValue; uint32Value = UInt32Value.FromUInt32(uint32); Assert.Equal(uint32, uint32Value.Value); Assert.Equal(uint32, UInt32Value.ToUInt32(uint32Value)); // 20. UInt64Value UInt64Value uint64Value = new UInt64Value(); UInt64 uint64 = UInt64.MaxValue; uint64Value = uint64; Assert.True(uint64 == uint64Value); uint64 = UInt64.MinValue; uint64Value = UInt64Value.FromUInt64(uint64); Assert.Equal(uint64, uint64Value.Value); Assert.Equal(uint64, UInt64Value.ToUInt64(uint64Value)); }
public LocalNativeRecord(MgReader reader, FixedWKTReader mgReader, MgAgfReaderWriter agfRw, MgWktReaderWriter wktRw) { for (int i = 0; i < reader.GetPropertyCount(); i++) { string name = reader.GetPropertyName(i); _ordinalMap[i] = name; var pt = (PropertyValueType)reader.GetPropertyType(name); switch (pt) { case PropertyValueType.Blob: _values[name] = new BlobValue(); break; case PropertyValueType.Boolean: _values[name] = new BooleanValue(); break; case PropertyValueType.Byte: _values[name] = new ByteValue(); break; case PropertyValueType.Clob: _values[name] = new ClobValue(); break; case PropertyValueType.DateTime: _values[name] = new DateTimeValue(); break; case PropertyValueType.Double: _values[name] = new DoubleValue(); break; case PropertyValueType.Feature: _values[name] = new FeatureValue(); break; case PropertyValueType.Geometry: _values[name] = new GeometryValue(); break; case PropertyValueType.Int16: _values[name] = new Int16Value(); break; case PropertyValueType.Int32: _values[name] = new Int32Value(); break; case PropertyValueType.Int64: _values[name] = new Int64Value(); break; case PropertyValueType.Raster: _values[name] = new RasterValue(); break; case PropertyValueType.Single: _values[name] = new SingleValue(); break; case PropertyValueType.String: _values[name] = new StringValue(); break; } } for (int i = 0; i < reader.GetPropertyCount(); i++) { string name = _ordinalMap[i]; GetByteReaderMethod getblob = () => { return reader.GetBLOB(name); }; GetByteReaderMethod getclob = () => { return reader.GetCLOB(name); }; GetByteReaderMethod getgeom = () => { return reader.GetGeometry(name); }; if (!reader.IsNull(name)) { var pt = (PropertyValueType)reader.GetPropertyType(name); switch (pt) { case PropertyValueType.Blob: ((BlobValue)_values[name]).Value = Utility.StreamAsArray(new MgReadOnlyStream(getblob)); break; case PropertyValueType.Boolean: ((BooleanValue)_values[name]).Value = reader.GetBoolean(name); break; case PropertyValueType.Byte: ((ByteValue)_values[name]).Value = reader.GetByte(name); break; case PropertyValueType.Clob: byte [] b = Utility.StreamAsArray(new MgReadOnlyStream(getclob)); ((ClobValue)_values[name]).Value = Encoding.UTF8.GetChars(b); break; case PropertyValueType.DateTime: ((DateTimeValue)_values[name]).Value = Utility.ConvertMgDateTime(reader.GetDateTime(name)); break; case PropertyValueType.Double: ((DoubleValue)_values[name]).Value = reader.GetDouble(name); break; //case PropertyValueType.Feature: case PropertyValueType.Geometry: try { //TODO: See if SWIG issues come into play here var geom = agfRw.Read(reader.GetGeometry(name)); var wkt = wktRw.Write(geom); ((GeometryValue)_values[name]).Value = mgReader.Read(wkt); } catch //Invalid geometry fail! { ((GeometryValue)_values[name]).SetNull(); } break; case PropertyValueType.Int16: ((Int16Value)_values[name]).Value = reader.GetInt16(name); break; case PropertyValueType.Int32: ((Int32Value)_values[name]).Value = reader.GetInt32(name); break; case PropertyValueType.Int64: ((Int64Value)_values[name]).Value = reader.GetInt64(name); break; case PropertyValueType.Single: ((SingleValue)_values[name]).Value = reader.GetSingle(name); break; case PropertyValueType.String: ((StringValue)_values[name]).Value = reader.GetString(name); break; } } } }
private static void AddImageToBody(WordprocessingDocument wordDoc, string relationshipId, uint id, string name, Int64Value cx, Int64Value cy) { // Define the reference of the image. var element = new Drawing( new DW.Inline( //new DW.Extent() { Cx = 990000L, Cy = 792000L }, new DW.Extent() { Cx = cx, Cy = cy }, new DW.EffectExtent() { LeftEdge = 0L, TopEdge = 0L, RightEdge = 0L, BottomEdge = 0L }, new DW.DocProperties() { //Id = (UInt32Value)1U, //Name = "Picture 1" Id = id, Name = name }, new DW.NonVisualGraphicFrameDrawingProperties( new A.GraphicFrameLocks()), // { NoChangeAspect = true } new A.Graphic( new A.GraphicData( new PIC.Picture( new PIC.NonVisualPictureProperties( new PIC.NonVisualDrawingProperties() { Id = (UInt32Value)0U, Name = "New Bitmap Image.jpg" }, new PIC.NonVisualPictureDrawingProperties()), new PIC.BlipFill( new A.Blip( new A.BlipExtensionList( new A.BlipExtension() { Uri = "{28A0092B-C50C-407E-A947-70E740481C1C}" }) ) { Embed = relationshipId, CompressionState = A.BlipCompressionValues.Print }, new A.Stretch( new A.FillRectangle())), new PIC.ShapeProperties( new A.Transform2D( new A.Offset() { X = 0L, Y = 0L }, //new A.Extents() { Cx = 990000L, Cy = 792000L }), new A.Extents() { Cx = cx, Cy = cy }), new A.PresetGeometry( new A.AdjustValueList() ) { Preset = A.ShapeTypeValues.Rectangle })) ) { Uri = "http://schemas.openxmlformats.org/drawingml/2006/picture" }) ) { DistanceFromTop = (UInt32Value)0U, DistanceFromBottom = (UInt32Value)0U, DistanceFromLeft = (UInt32Value)0U, DistanceFromRight = (UInt32Value)0U, EditId = "50D07946" }); // Append the reference to body, the element should be in a Run. wordDoc.MainDocumentPart.Document.Body.AppendChild(new Paragraph(new Run(element))); }
/// <summary> /// Returns a System.String that represents the current PropVariant. /// </summary> /// <returns>A System.String that represents the current PropVariant.</returns> public override string ToString() { return("[" + Value + "] " + Int64Value.ToString(CultureInfo.CurrentCulture)); }
public static double EmuToPoint(this Int64Value value) { return(value.Value.EmuToPoint()); }
public void AddImageToBody(WordprocessingDocument wordDoc, string relationshipId, Int64Value cx, Int64Value cy, string pictureName = null) { var element = new Drawing( new Wp.Inline( new Wp.Extent() { Cx = cx, Cy = cy }, new Wp.EffectExtent() { LeftEdge = 0L, TopEdge = 0L, RightEdge = 0L, BottomEdge = 0L }, new Wp.DocProperties() { Id = 1U, Name = pictureName }, new Wp.NonVisualGraphicFrameDrawingProperties( new A.GraphicFrameLocks() { NoChangeAspect = true }), new A.Graphic( new A.GraphicData( new Pic.Picture( new Pic.NonVisualPictureProperties( new Pic.NonVisualDrawingProperties() { Id = 0U, Name = $"{pictureName}.jpg" }, new Pic.NonVisualPictureDrawingProperties()), new Pic.BlipFill( new A.Blip( new A.BlipExtensionList( new A.BlipExtension() { Uri = "{28A0092B-C50C-407E-A947-70E740481C1C}" }) ) { Embed = relationshipId, CompressionState = A.BlipCompressionValues.Print }, new A.Stretch( new A.FillRectangle())), new Pic.ShapeProperties( new A.Transform2D( new A.Offset() { X = 0L, Y = 0L }, new A.Extents() { Cx = cx, Cy = cy }), new A.PresetGeometry( new A.AdjustValueList() ) { Preset = A.ShapeTypeValues.Rectangle })) ) { Uri = "http://schemas.openxmlformats.org/drawingml/2006/picture" }) ) { DistanceFromTop = 0U, DistanceFromBottom = 0U, DistanceFromLeft = 114300U, DistanceFromRight = 114300U, EditId = "50D07946" }); wordDoc.MainDocumentPart.Document.Body.AppendChild( new Paragraph(new Run(element)) { ParagraphProperties = new ParagraphProperties { Justification = new Justification { Val = JustificationValues.Center } } }); }
private static void AddMainLogo(OpenXmlElement elementToAppend, string relationshipId) { var element = new Drawing { Inline = new Inline { DistanceFromTop = UInt32Value.FromUInt32(0), DistanceFromBottom = UInt32Value.FromUInt32(0), DistanceFromLeft = UInt32Value.FromUInt32(0), DistanceFromRight = UInt32Value.FromUInt32(0), AnchorId = HexBinaryValue.FromString("29B39BAA"), EditId = HexBinaryValue.FromString("5481AAF3"), Extent = new Extent { Cx = Int64Value.FromInt64(1257300), Cy = Int64Value.FromInt64(1057275) }, EffectExtent = new EffectExtent { LeftEdge = Int64Value.FromInt64(0), TopEdge = Int64Value.FromInt64(0), RightEdge = Int64Value.FromInt64(0), BottomEdge = Int64Value.FromInt64(0) }, DocProperties = new DocProperties { Id = UInt32Value.FromUInt32(1), Name = "Picture 1" }, NonVisualGraphicFrameDrawingProperties = new NonVisualGraphicFrameDrawingProperties { GraphicFrameLocks = new GraphicFrameLocks { NoChangeAspect = BooleanValue.FromBoolean(true) } }, Graphic = new Graphic { GraphicData = new GraphicData(new DocumentFormat.OpenXml.Drawing.Pictures.Picture { NonVisualPictureProperties = new DocumentFormat.OpenXml.Drawing.Pictures.NonVisualPictureProperties { NonVisualDrawingProperties = new DocumentFormat.OpenXml.Drawing.Pictures.NonVisualDrawingProperties { Id = UInt32Value.FromUInt32(0), Name = "Picture 1" }, NonVisualPictureDrawingProperties = new DocumentFormat.OpenXml.Drawing.Pictures.NonVisualPictureDrawingProperties { PictureLocks = new PictureLocks { NoChangeAspect = BooleanValue.FromBoolean(true), NoChangeArrowheads = BooleanValue.FromBoolean(true) } } }, BlipFill = new DocumentFormat.OpenXml.Drawing.Pictures.BlipFill(new BlipExtensionList(new BlipExtension { Uri = "{28A0092B-C50C-407E-A947-70E740481C1C}" }), new Stretch(new FillRectangle())) { Blip = new Blip { Embed = relationshipId, }, SourceRectangle = new SourceRectangle(), }, ShapeProperties = new DocumentFormat.OpenXml.Drawing.Pictures.ShapeProperties(new PresetGeometry { Preset = new EnumValue <ShapeTypeValues> { Value = ShapeTypeValues.Rectangle }, AdjustValueList = new AdjustValueList() }, new NoFill(), new DocumentFormat.OpenXml.Drawing.Outline(new NoFill())) { BlackWhiteMode = new EnumValue <BlackWhiteModeValues> { Value = BlackWhiteModeValues.Auto }, Transform2D = new Transform2D { Offset = new Offset { X = Int64Value.FromInt64(0), Y = Int64Value.FromInt64(0) }, Extents = new Extents { Cx = Int64Value.FromInt64(1257300), Cy = Int64Value.FromInt64(1057275) } } } }) { Uri = "http://schemas.openxmlformats.org/drawingml/2006/picture" } } } }; // Append the reference to body, the element should be in a Run. elementToAppend.AppendChild(new Paragraph(new Run(element) { RunProperties = new DocumentFormat.OpenXml.Wordprocessing.RunProperties { NoProof = new NoProof() } })); }
private void DrawLine(Wpg.WordprocessingGroup wordprocessingGroup1, Rect extents, Point startPoint, Point endPoint, string colour, int thick) { UInt32Value bondLineId = UInt32Value.FromUInt32((uint)_ooxmlId++); string bondLineName = "diag-line-" + bondLineId; // Move Bond Line Extents and Points to have 0,0 Top Left Reference startPoint.Offset(-_canvasExtents.Left, -_canvasExtents.Top); endPoint.Offset(-_canvasExtents.Left, -_canvasExtents.Top); extents.Offset(-_canvasExtents.Left, -_canvasExtents.Top); // Move points into New Bond Line Extents startPoint.Offset(-extents.Left, -extents.Top); endPoint.Offset(-extents.Left, -extents.Top); Int64Value width = OoXmlHelper.ScaleCmlToEmu(extents.Width); Int64Value height = OoXmlHelper.ScaleCmlToEmu(extents.Height); Int64Value top = OoXmlHelper.ScaleCmlToEmu(extents.Top); Int64Value left = OoXmlHelper.ScaleCmlToEmu(extents.Left); Wps.WordprocessingShape wordprocessingShape1 = new Wps.WordprocessingShape(); Wps.NonVisualDrawingProperties nonVisualDrawingProperties1 = new Wps.NonVisualDrawingProperties() { Id = bondLineId, Name = bondLineName }; Wps.NonVisualDrawingShapeProperties nonVisualDrawingShapeProperties1 = new Wps.NonVisualDrawingShapeProperties(); Wps.ShapeProperties shapeProperties1 = new Wps.ShapeProperties(); A.Transform2D transform2D1 = new A.Transform2D(); A.Offset offset2 = new A.Offset() { X = left, Y = top }; A.Extents extents2 = new A.Extents() { Cx = width, Cy = height }; transform2D1.Append(offset2); transform2D1.Append(extents2); A.CustomGeometry customGeometry1 = new A.CustomGeometry(); A.AdjustValueList adjustValueList1 = new A.AdjustValueList(); A.Rectangle rectangle1 = new A.Rectangle() { Left = "l", Top = "t", Right = "r", Bottom = "b" }; A.PathList pathList1 = new A.PathList(); A.Path path1 = new A.Path() { Width = width, Height = height }; A.MoveTo moveTo1 = new A.MoveTo(); A.Point point1 = new A.Point() { X = OoXmlHelper.ScaleCmlToEmu(startPoint.X).ToString(), Y = OoXmlHelper.ScaleCmlToEmu(startPoint.Y).ToString() }; moveTo1.Append(point1); A.LineTo lineTo1 = new A.LineTo(); A.Point point2 = new A.Point() { X = OoXmlHelper.ScaleCmlToEmu(endPoint.X).ToString(), Y = OoXmlHelper.ScaleCmlToEmu(endPoint.Y).ToString() }; lineTo1.Append(point2); path1.Append(moveTo1); path1.Append(lineTo1); pathList1.Append(path1); customGeometry1.Append(adjustValueList1); customGeometry1.Append(rectangle1); customGeometry1.Append(pathList1); A.Outline outline1 = new A.Outline() { Width = thick, CapType = A.LineCapValues.Round }; A.SolidFill solidFill1 = new A.SolidFill(); A.RgbColorModelHex rgbColorModelHex1 = new A.RgbColorModelHex() { Val = colour }; A.Alpha alpha1 = new A.Alpha() { Val = new Int32Value() { InnerText = "100%" } }; rgbColorModelHex1.Append(alpha1); solidFill1.Append(rgbColorModelHex1); outline1.Append(solidFill1); shapeProperties1.Append(transform2D1); shapeProperties1.Append(customGeometry1); shapeProperties1.Append(outline1); Wps.ShapeStyle shapeStyle1 = new Wps.ShapeStyle(); A.LineReference lineReference1 = new A.LineReference() { Index = (UInt32Value)0U }; A.FillReference fillReference1 = new A.FillReference() { Index = (UInt32Value)0U }; A.EffectReference effectReference1 = new A.EffectReference() { Index = (UInt32Value)0U }; A.FontReference fontReference1 = new A.FontReference() { Index = A.FontCollectionIndexValues.Minor }; shapeStyle1.Append(lineReference1); shapeStyle1.Append(fillReference1); shapeStyle1.Append(effectReference1); shapeStyle1.Append(fontReference1); Wps.TextBodyProperties textBodyProperties1 = new Wps.TextBodyProperties(); wordprocessingShape1.Append(nonVisualDrawingProperties1); wordprocessingShape1.Append(nonVisualDrawingShapeProperties1); wordprocessingShape1.Append(shapeProperties1); wordprocessingShape1.Append(shapeStyle1); wordprocessingShape1.Append(textBodyProperties1); wordprocessingGroup1.Append(wordprocessingShape1); }
private void DrawShape(Wpg.WordprocessingGroup wordprocessingGroup1, Rect extents, A.ShapeTypeValues shape, string colour) { UInt32Value bondLineId = UInt32Value.FromUInt32((uint)_ooxmlId++); string bondLineName = "shape" + bondLineId; Int64Value width1 = OoXmlHelper.ScaleCmlToEmu(extents.Width); Int64Value height1 = OoXmlHelper.ScaleCmlToEmu(extents.Height); Int64Value top1 = OoXmlHelper.ScaleCmlToEmu(extents.Top); Int64Value left1 = OoXmlHelper.ScaleCmlToEmu(extents.Left); Point pp1 = new Point(left1, top1); Size ss2 = new Size(width1, height1); pp1.Offset(OoXmlHelper.ScaleCmlToEmu(-_canvasExtents.Left), OoXmlHelper.ScaleCmlToEmu(-_canvasExtents.Top)); Rect boundingBox = new Rect(pp1, ss2); Int64Value width = (Int64Value)boundingBox.Width; Int64Value height = (Int64Value)boundingBox.Height; Int64Value top = (Int64Value)boundingBox.Top; Int64Value left = (Int64Value)boundingBox.Left; A.Extents extents2 = null; A.PresetGeometry presetGeometry1 = null; extents2 = new A.Extents() { Cx = width, Cy = height }; presetGeometry1 = new A.PresetGeometry() { Preset = shape }; Wps.WordprocessingShape wordprocessingShape1 = new Wps.WordprocessingShape(); Wps.NonVisualDrawingProperties nonVisualDrawingProperties1 = new Wps.NonVisualDrawingProperties() { Id = bondLineId, Name = bondLineName }; Wps.NonVisualDrawingShapeProperties nonVisualDrawingShapeProperties1 = new Wps.NonVisualDrawingShapeProperties(); Wps.ShapeProperties shapeProperties1 = new Wps.ShapeProperties(); A.Transform2D transform2D1 = new A.Transform2D(); A.Offset offset2 = new A.Offset() { X = left, Y = top }; transform2D1.Append(offset2); transform2D1.Append(extents2); A.AdjustValueList adjustValueList1 = new A.AdjustValueList(); presetGeometry1.Append(adjustValueList1); A.SolidFill solidFill1 = new A.SolidFill(); A.RgbColorModelHex rgbColorModelHex1 = new A.RgbColorModelHex() { Val = colour }; A.Alpha alpha1 = new A.Alpha() { Val = new Int32Value() { InnerText = "100%" } }; solidFill1.Append(rgbColorModelHex1); shapeProperties1.Append(transform2D1); shapeProperties1.Append(presetGeometry1); shapeProperties1.Append(solidFill1); Wps.ShapeStyle shapeStyle1 = new Wps.ShapeStyle(); A.LineReference lineReference1 = new A.LineReference() { Index = (UInt32Value)0U }; A.FillReference fillReference1 = new A.FillReference() { Index = (UInt32Value)0U }; A.EffectReference effectReference1 = new A.EffectReference() { Index = (UInt32Value)0U }; A.FontReference fontReference1 = new A.FontReference() { Index = A.FontCollectionIndexValues.Minor }; shapeStyle1.Append(lineReference1); shapeStyle1.Append(fillReference1); shapeStyle1.Append(effectReference1); shapeStyle1.Append(fontReference1); Wps.TextBodyProperties textBodyProperties1 = new Wps.TextBodyProperties(); wordprocessingShape1.Append(nonVisualDrawingProperties1); wordprocessingShape1.Append(nonVisualDrawingShapeProperties1); wordprocessingShape1.Append(shapeProperties1); wordprocessingShape1.Append(shapeStyle1); wordprocessingShape1.Append(textBodyProperties1); wordprocessingGroup1.Append(wordprocessingShape1); }
public override CrossChainMerkleProofContext GetBoundParentChainHeightAndMerklePathByHeight(Int64Value input) { var boundParentChainHeight = State.ChildHeightToParentChainHeight[input.Value]; Assert(boundParentChainHeight != 0); var merklePath = State.TxRootMerklePathInParentChain[input.Value]; Assert(merklePath != null); return(new CrossChainMerkleProofContext { MerklePathFromParentChain = merklePath, BoundParentChainHeight = boundParentChainHeight }); }
public object ChangeType_Int64() { return(Int64Value.ChangeType(typeof(Int64), CultureInfo.InvariantCulture)); }
public override IndexedSideChainBlockData GetIndexedSideChainBlockDataByHeight(Int64Value input) { var indexedSideChainBlockData = State.IndexedSideChainBlockData[input.Value]; return(indexedSideChainBlockData ?? new IndexedSideChainBlockData()); }
public override PeriodBody GetPeriod(Int64Value input) { var period = State.Periods[input.Value]; return(period ?? new PeriodBody()); }
public override Lottery GetLottery(Int64Value input) { return(State.Lotteries[input.Value]); }
public XmlRecord(XmlProperty[] properties, FixedWKTReader wktReader, XmlNodeList propertyNodes, string nameElement, string valueElement) { for (int i = 0; i < properties.Length; i++) { string name = properties[i].Name; _ordinalMap[i] = name; switch (properties[i].Type) { case PropertyValueType.Blob: _values[name] = new BlobValue(); break; case PropertyValueType.Boolean: _values[name] = new BooleanValue(); break; case PropertyValueType.Byte: _values[name] = new ByteValue(); break; case PropertyValueType.Clob: _values[name] = new ClobValue(); break; case PropertyValueType.DateTime: _values[name] = new DateTimeValue(); break; case PropertyValueType.Double: _values[name] = new DoubleValue(); break; case PropertyValueType.Feature: _values[name] = new FeatureValue(); break; case PropertyValueType.Geometry: _values[name] = new GeometryValue(); break; case PropertyValueType.Int16: _values[name] = new Int16Value(); break; case PropertyValueType.Int32: _values[name] = new Int32Value(); break; case PropertyValueType.Int64: _values[name] = new Int64Value(); break; case PropertyValueType.Raster: _values[name] = new RasterValue(); break; case PropertyValueType.Single: _values[name] = new SingleValue(); break; case PropertyValueType.String: _values[name] = new StringValue(); break; } } foreach (XmlNode propNode in propertyNodes) { var name = propNode[nameElement].InnerText; var valueNode = propNode[valueElement]; if (valueNode != null) { var value = valueNode.InnerText; switch (_values[name].Type) { case PropertyValueType.Blob: ((BlobValue)_values[name]).Value = Encoding.UTF8.GetBytes(value); break; case PropertyValueType.Boolean: ((BooleanValue)_values[name]).Value = XmlConvert.ToBoolean(value); break; case PropertyValueType.Byte: ((ByteValue)_values[name]).Value = XmlConvert.ToByte(value); break; case PropertyValueType.Clob: ((ClobValue)_values[name]).Value = value.ToCharArray(); break; case PropertyValueType.DateTime: var dt = ConvertToDateTime(value); if (dt.HasValue) ((DateTimeValue)_values[name]).Value = dt.Value; break; case PropertyValueType.Double: ((DoubleValue)_values[name]).Value = XmlConvert.ToDouble(value); break; case PropertyValueType.Feature: ((FeatureValue)_values[name]).Value = ConvertToFeatures(value); break; case PropertyValueType.Geometry: ((GeometryValue)_values[name]).Value = wktReader.Read(value); break; case PropertyValueType.Int16: ((Int16Value)_values[name]).Value = XmlConvert.ToInt16(value); break; case PropertyValueType.Int32: ((Int32Value)_values[name]).Value = XmlConvert.ToInt32(value); break; case PropertyValueType.Int64: ((Int64Value)_values[name]).Value = XmlConvert.ToInt64(value); break; case PropertyValueType.Raster: ((RasterValue)_values[name]).Value = ConvertToRaster(value); break; case PropertyValueType.Single: ((SingleValue)_values[name]).Value = XmlConvert.ToSingle(value); break; case PropertyValueType.String: ((StringValue)_values[name]).Value = value; break; } } } }
private Wp.Inline CreateInline(A.GraphicData graphicData, Wpg.WordprocessingGroup wordprocessingGroup1) { UInt32Value inlineId = UInt32Value.FromUInt32((uint)_ooxmlId++); Int64Value width = OoXmlHelper.ScaleCmlToEmu(_canvasExtents.Width); Int64Value height = OoXmlHelper.ScaleCmlToEmu(_canvasExtents.Height); Wp.Inline inline1 = new Wp.Inline() { DistanceFromTop = (UInt32Value)0U, DistanceFromBottom = (UInt32Value)0U, DistanceFromLeft = (UInt32Value)0U, DistanceFromRight = (UInt32Value)0U }; Wp.Extent extent1 = new Wp.Extent() { Cx = width, Cy = height }; Wp.EffectExtent effectExtent1 = new Wp.EffectExtent() { LeftEdge = 0L, TopEdge = 0L, RightEdge = 0L, BottomEdge = 0L }; Wp.DocProperties docProperties1 = new Wp.DocProperties() { Id = inlineId, Name = "moleculeGroup" }; Wpg.NonVisualGroupDrawingShapeProperties nonVisualGroupDrawingShapeProperties1 = new Wpg.NonVisualGroupDrawingShapeProperties(); Wpg.NonVisualGraphicFrameProperties nonVisualGraphicFrameProperties = new Wpg.NonVisualGraphicFrameProperties(); A.GraphicFrameLocks gfl = new A.GraphicFrameLocks() { NoMove = true, NoSelection = true }; Wpg.GroupShapeProperties groupShapeProperties1 = new Wpg.GroupShapeProperties(); A.TransformGroup transformGroup1 = new A.TransformGroup(); A.Offset offset1 = new A.Offset() { X = 0L, Y = 0L }; A.Extents extents1 = new A.Extents() { Cx = width, Cy = height }; A.ChildOffset childOffset1 = new A.ChildOffset() { X = 0L, Y = 0L }; A.ChildExtents childExtents1 = new A.ChildExtents() { Cx = width, Cy = height }; transformGroup1.Append(offset1); transformGroup1.Append(extents1); transformGroup1.Append(childOffset1); transformGroup1.Append(childExtents1); groupShapeProperties1.Append(transformGroup1); wordprocessingGroup1.Append(nonVisualGroupDrawingShapeProperties1); wordprocessingGroup1.Append(groupShapeProperties1); inline1.Append(extent1); inline1.Append(effectExtent1); inline1.Append(docProperties1); inline1.Append(gfl); return(inline1); }
/// <summary> /// Gets the values. /// </summary> /// <returns></returns> public Dictionary<string, ValueExpression> GetValues() { Dictionary<string, ValueExpression> values = new Dictionary<string, ValueExpression>(); foreach (DataGridViewRow row in grdProperties.Rows) { string name = row.Cells[0].Value.ToString(); PropertyDefinition propDef = row.Cells[0].Tag as PropertyDefinition; if (row.Cells[1].Value != null) { string str = row.Cells[1].Value.ToString(); if (!string.IsNullOrEmpty(str)) { ValueExpression expr = null; if (propDef.PropertyType == PropertyType.PropertyType_DataProperty) { DataPropertyDefinition dp = propDef as DataPropertyDefinition; switch (dp.DataType) { case DataType.DataType_Boolean: expr = new BooleanValue(Convert.ToBoolean(str)); break; case DataType.DataType_Byte: expr = new ByteValue(Convert.ToByte(str)); break; case DataType.DataType_DateTime: expr = new DateTimeValue(Convert.ToDateTime(str)); break; case DataType.DataType_Decimal: expr = new DecimalValue(Convert.ToDouble(str)); break; case DataType.DataType_Double: expr = new DoubleValue(Convert.ToDouble(str)); break; case DataType.DataType_Int16: expr = new Int16Value(Convert.ToInt16(str)); break; case DataType.DataType_Int32: expr = new Int32Value(Convert.ToInt32(str)); break; case DataType.DataType_Int64: expr = new Int64Value(Convert.ToInt64(str)); break; case DataType.DataType_Single: expr = new SingleValue(Convert.ToSingle(str)); break; case DataType.DataType_String: expr = new StringValue(str); break; default: throw new NotSupportedException("Unsupported data type: " + dp.DataType); } } else if (propDef.PropertyType == PropertyType.PropertyType_GeometricProperty) { FdoGeometryFactory fact = FdoGeometryFactory.Instance; OSGeo.FDO.Geometry.IGeometry geom = fact.CreateGeometry(str); byte[] fgf = fact.GetFgf(geom); expr = new GeometryValue(fgf); geom.Dispose(); } if (expr != null) values.Add(name, expr); } } } return values; }
/// <summary> /// Adds an image to the container which can then be added to a paragraph /// </summary> /// <param name="stream"></param> /// <param name="contentType"></param> /// <param name="width">The width of the image in English Metric Units (EMU)</param> /// <param name="height">The height of the image in English Metric Units (EMU)</param> /// <param name="name">The name of the image. Leave blank to generate a Guid</param> /// <returns></returns> public Drawing AddImage(Stream stream, string contentType, Int64Value width, Int64Value height, string name = "") { return(DocX.CreateDrawing(AddImagePart(stream, contentType), width, height, name)); }
// Convert JSValue to a readable string that can be used for logging and debugging. public override string ToString() { switch (Type) { case JSValueType.Null: return(JSConverter.NullString); case JSValueType.Object: { var sb = new StringBuilder(); sb.Append("{"); bool start = true; foreach (var prop in ObjectValue) { if (start) { start = false; } else { sb.Append(", "); } sb.Append(prop.Key); sb.Append(": "); sb.Append(prop.Value.ToString()); } sb.Append("}"); return(sb.ToString()); } case JSValueType.Array: { var sb = new StringBuilder(); sb.Append("["); bool start = true; foreach (var item in ArrayValue) { if (start) { start = false; } else { sb.Append(", "); } sb.Append(item.ToString()); } sb.Append("]"); return(sb.ToString()); } case JSValueType.String: return("\"" + StringValue + "\""); case JSValueType.Boolean: return(JSConverter.ToJSString(BooleanValue)); case JSValueType.Int64: return(Int64Value.ToString()); case JSValueType.Double: return(JSConverter.ToJSString(DoubleValue)); default: return("<Unexpected>"); } }
public Drawing AppendImage(byte[] data, string contentType, Int64Value width, Int64Value height, string name = "") { var image = AddImage(data, contentType, width, height, name); AddParagraph().Append(image); return(image); }
public static Int64Value Conv_Ovf_U8_Un(Real8Value a) { return(Int64Value.CreateUnknown()); }
public static Int64Value Conv_Ovf_U8_Un(Real8Value a) => Int64Value.CreateUnknown();
private void DrawCharacterBox(Wpg.WordprocessingGroup wordprocessingGroup1, Rect extents, string colour, int thick) { UInt32Value bondLineId = UInt32Value.FromUInt32((uint)m_ooxmlId++); string bondLineName = "box" + bondLineId; Int64Value width = (Int64Value)extents.Width; Int64Value height = (Int64Value)extents.Height; Int64Value top = (Int64Value)extents.Top; Int64Value left = (Int64Value)extents.Left; Wps.WordprocessingShape wordprocessingShape1 = new Wps.WordprocessingShape(); Wps.NonVisualDrawingProperties nonVisualDrawingProperties1 = new Wps.NonVisualDrawingProperties() { Id = bondLineId, Name = bondLineName }; Wps.NonVisualDrawingShapeProperties nonVisualDrawingShapeProperties1 = new Wps.NonVisualDrawingShapeProperties(); Wps.ShapeProperties shapeProperties1 = new Wps.ShapeProperties(); A.Transform2D transform2D1 = new A.Transform2D(); A.Offset offset2 = new A.Offset() { X = left, Y = top }; A.Extents extents2 = new A.Extents() { Cx = width, Cy = height }; transform2D1.Append(offset2); transform2D1.Append(extents2); A.CustomGeometry customGeometry1 = new A.CustomGeometry(); A.AdjustValueList adjustValueList1 = new A.AdjustValueList(); A.Rectangle rectangle1 = new A.Rectangle() { Left = "l", Top = "t", Right = "r", Bottom = "b" }; A.PathList pathList1 = new A.PathList(); A.Path path1 = new A.Path() { Width = width, Height = height }; // Starting Point A.MoveTo moveTo1 = new A.MoveTo(); A.Point point1 = new A.Point() { X = "0", Y = "0" }; moveTo1.Append(point1); // Mid Point A.LineTo lineTo1 = new A.LineTo(); A.Point point2 = new A.Point() { X = extents.Width.ToString("0"), Y = "0" }; lineTo1.Append(point2); // Mid Point A.LineTo lineTo2 = new A.LineTo(); A.Point point3 = new A.Point() { X = extents.Width.ToString("0"), Y = extents.Height.ToString("0") }; lineTo2.Append(point3); // Last Point A.LineTo lineTo3 = new A.LineTo(); A.Point point4 = new A.Point() { X = "0", Y = extents.Height.ToString("0") }; lineTo3.Append(point4); // Back to Start Point A.LineTo lineTo4 = new A.LineTo(); A.Point point5 = new A.Point() { X = "0", Y = "0" }; lineTo4.Append(point5); path1.Append(moveTo1); path1.Append(lineTo1); path1.Append(lineTo2); path1.Append(lineTo3); path1.Append(lineTo4); pathList1.Append(path1); customGeometry1.Append(adjustValueList1); customGeometry1.Append(rectangle1); customGeometry1.Append(pathList1); A.Outline outline1 = new A.Outline() { Width = thick, CapType = A.LineCapValues.Round }; A.SolidFill solidFill1 = new A.SolidFill(); A.RgbColorModelHex rgbColorModelHex1 = new A.RgbColorModelHex() { Val = colour }; A.Alpha alpha1 = new A.Alpha() { Val = new Int32Value() { InnerText = "100%" } }; rgbColorModelHex1.Append(alpha1); solidFill1.Append(rgbColorModelHex1); outline1.Append(solidFill1); shapeProperties1.Append(transform2D1); shapeProperties1.Append(customGeometry1); shapeProperties1.Append(outline1); Wps.ShapeStyle shapeStyle1 = new Wps.ShapeStyle(); A.LineReference lineReference1 = new A.LineReference() { Index = (UInt32Value)0U }; A.FillReference fillReference1 = new A.FillReference() { Index = (UInt32Value)0U }; A.EffectReference effectReference1 = new A.EffectReference() { Index = (UInt32Value)0U }; A.FontReference fontReference1 = new A.FontReference() { Index = A.FontCollectionIndexValues.Minor }; shapeStyle1.Append(lineReference1); shapeStyle1.Append(fillReference1); shapeStyle1.Append(effectReference1); shapeStyle1.Append(fontReference1); Wps.TextBodyProperties textBodyProperties1 = new Wps.TextBodyProperties(); wordprocessingShape1.Append(nonVisualDrawingProperties1); wordprocessingShape1.Append(nonVisualDrawingShapeProperties1); wordprocessingShape1.Append(shapeProperties1); wordprocessingShape1.Append(shapeStyle1); wordprocessingShape1.Append(textBodyProperties1); wordprocessingGroup1.Append(wordprocessingShape1); }
internal static OpenXmlSimpleType[] CreatePossibleMembers(UnionValueRestriction unionValueRestriction) { OpenXmlSimpleType[] simpleValues = new OpenXmlSimpleType[unionValueRestriction.UnionTypes.Length]; switch (unionValueRestriction.UnionId) { // ST_AnimationDgmBuildType case 25: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Drawing.AnimationBuildValues>(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.Drawing.AnimationDiagramOnlyBuildValues>(); break; // ST_AnimationChartBuildType case 27: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Drawing.AnimationBuildValues>(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.Drawing.AnimationChartOnlyBuildValues>(); break; // ST_AdjCoordinate case 45: simpleValues[0] = new Int64Value(); simpleValues[1] = new StringValue(); break; // ST_AdjAngle case 46: simpleValues[0] = new Int32Value(); simpleValues[1] = new StringValue(); break; // ST_LayoutShapeType case 145: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Drawing.ShapeTypeValues>(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.OutputShapeValues>(); break; // ST_ParameterVal case 183: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.HorizontalAlignmentValues>(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.VerticalAlignmentValues>(); simpleValues[2] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.ChildDirectionValues>(); simpleValues[3] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.ChildAlignmentValues>(); simpleValues[4] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.SecondaryChildAlignmentValues>(); simpleValues[5] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.LinearDirectionValues>(); simpleValues[6] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.SecondaryLinearDirectionValues>(); simpleValues[7] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.StartingElementValues>(); simpleValues[8] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.BendPointValues>(); simpleValues[9] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.ConnectorRoutingValues>(); simpleValues[10] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.ArrowheadStyleValues>(); simpleValues[11] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.ConnectorDimensionValues>(); simpleValues[12] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.RotationPathValues>(); simpleValues[13] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.CenterShapeMappingValues>(); simpleValues[14] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.NodeHorizontalAlignmentValues>(); simpleValues[15] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.NodeVerticalAlignmentValues>(); simpleValues[16] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.FallbackDimensionValues>(); simpleValues[17] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.TextDirectionValues>(); simpleValues[18] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.PyramidAccentPositionValues>(); simpleValues[19] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.PyramidAccentTextMarginValues>(); simpleValues[20] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.TextBlockDirectionValues>(); simpleValues[21] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.TextAnchorHorizontalValues>(); simpleValues[22] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.TextAnchorVerticalValues>(); simpleValues[23] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.TextAlignmentValues>(); simpleValues[24] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.AutoTextRotationValues>(); simpleValues[25] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.GrowDirectionValues>(); simpleValues[26] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.FlowDirectionValues>(); simpleValues[27] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.ContinueDirectionValues>(); simpleValues[28] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.BreakpointValues>(); simpleValues[29] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.OffsetValues>(); simpleValues[30] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.HierarchyAlignmentValues>(); simpleValues[31] = new Int32Value(); simpleValues[32] = new DoubleValue(); simpleValues[33] = new BooleanValue(); simpleValues[34] = new StringValue(); simpleValues[35] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.ConnectorPointValues>(); break; // ST_ModelId case 184: simpleValues[0] = new Int32Value(); simpleValues[1] = new StringValue(); break; // ST_FunctionValue case 207: simpleValues[0] = new Int32Value(); simpleValues[1] = new BooleanValue(); simpleValues[2] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.DirectionValues>(); simpleValues[3] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.HierarchyBranchStyleValues>(); simpleValues[4] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.AnimateOneByOneValues>(); simpleValues[5] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.AnimationLevelStringValues>(); simpleValues[6] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.ResizeHandlesStringValues>(); break; // ST_FunctionArgument case 209: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.VariableValues>(); break; // ST_NonZeroDecimalNumber case 368: simpleValues[0] = new Int32Value(); simpleValues[1] = new Int32Value(); break; // ST_MarkupId case 375: simpleValues[0] = new Int32Value(); simpleValues[1] = new Int32Value(); break; // ST_HexColor case 404: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Wordprocessing.AutomaticColorValues>(); simpleValues[1] = new HexBinaryValue(); break; // ST_DecimalNumberOrPercent case 507: simpleValues[0] = new StringValue(); simpleValues[1] = new Int32Value(); break; // ST_SignedHpsMeasure_O14 case 525: simpleValues[0] = new IntegerValue(); simpleValues[1] = new StringValue(); break; // ST_HpsMeasure_O14 case 528: simpleValues[0] = new UInt32Value(); simpleValues[1] = new StringValue(); break; // ST_SignedTwipsMeasure_O14 case 531: simpleValues[0] = new IntegerValue(); simpleValues[1] = new StringValue(); break; // ST_TwipsMeasure_O14 case 534: simpleValues[0] = new UInt32Value(); simpleValues[1] = new StringValue(); break; // ST_TransitionEightDirectionType case 544: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Presentation.TransitionSlideDirectionValues>(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.Presentation.TransitionCornerDirectionValues>(); break; // ST_TLTimeAnimateValueTime case 561: simpleValues[0] = new Int32Value(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.Presentation.IndefiniteTimeDeclarationValues>(); break; // ST_TLTime_O12 case 603: simpleValues[0] = new UInt32Value(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.Presentation.IndefiniteTimeDeclarationValues>(); break; // ST_TLTime_O14 case 604: simpleValues[0] = new StringValue(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.Presentation.IndefiniteTimeDeclarationValues>(); break; // ST_PublishDate case 689: simpleValues[0] = new DateTimeValue(); simpleValues[1] = new DateTimeValue(); simpleValues[2] = new StringValue(); break; // ST_ChannelDataPoint case 697: simpleValues[0] = new DecimalValue(); simpleValues[1] = new BooleanValue(); break; // ST_ChannelPropertyName case 701: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardChannelPropertyNameValues>(); simpleValues[1] = new StringValue(); break; // ST_BrushPropertyName case 704: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardBrushPropertyNameValues>(); simpleValues[1] = new StringValue(); break; // ST_ChannelName case 707: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardChannelNameValues>(); simpleValues[1] = new StringValue(); break; // ST_Units case 719: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardLengthUnitsValues>(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardPerLengthUnitsValues>(); simpleValues[2] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardTimeUnitsValues>(); simpleValues[3] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardPerTimeUnitsValues>(); simpleValues[4] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardMassForceUnitsValues>(); simpleValues[5] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardPerMassForceUnitsValues>(); simpleValues[6] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardAngleUnitsValues>(); simpleValues[7] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardPerAngleUnitsValues>(); simpleValues[8] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardOtherUnitsValues>(); simpleValues[9] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardPerOtherUnitsValues>(); simpleValues[10] = new StringValue(); break; // ST_BrushPropertyValue case 732: simpleValues[0] = new DecimalValue(); simpleValues[1] = new BooleanValue(); simpleValues[2] = new EnumValue <DocumentFormat.OpenXml.InkML.PenTipShapeValues>(); simpleValues[3] = new EnumValue <DocumentFormat.OpenXml.InkML.RasterOperationValues>(); simpleValues[4] = new StringValue(); break; // ST_Ref case 746: simpleValues[0] = new StringValue(); simpleValues[1] = new UInt32Value(); break; // ST_CtxNodeType case 747: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Office2010.Ink.KnownContextNodeTypeValues>(); simpleValues[1] = new StringValue(); break; // ST_SemanticType case 750: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Office2010.Ink.KnownSemanticTypeValues>(); simpleValues[1] = new UInt32Value(); break; // ST_PointsOrInt case 753: simpleValues[0] = new ListValue <StringValue>(); simpleValues[1] = new Int32Value(); break; // ST_TransitionCornerAndCenterDirectionType case 766: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Presentation.TransitionCornerDirectionValues>(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.Office2010.PowerPoint.TransitionCenterDirectionTypeValues>(); break; // ST_ColorStyleMethod case 835: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Office2013.Drawing.ChartStyle.ColorStyleMethodEnum>(); simpleValues[1] = new StringValue(); break; // ST_StyleReferenceModifier case 837: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Office2013.Drawing.ChartStyle.StyleReferenceModifierEnum>(); simpleValues[1] = new StringValue(); break; // ST_StyleColorVal case 840: simpleValues[0] = new UInt32Value(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.Office2013.Drawing.ChartStyle.StyleColorEnum>(); simpleValues[2] = new StringValue(); break; // ST_StyleEntryModifier case 842: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Office2013.Drawing.ChartStyle.StyleEntryModifierEnum>(); simpleValues[1] = new StringValue(); break; default: Debug.Assert(false); break; } Debug.Assert(simpleValues.Length > 0); return(simpleValues); }
public void DrawCharacter(Wpg.WordprocessingGroup wordprocessingGroup1, AtomLabelCharacter alc) { Point characterPosition = new Point(alc.Position.X, alc.Position.Y); characterPosition.Offset(-m_canvasExtents.Left, -m_canvasExtents.Top); UInt32Value atomLabelId = UInt32Value.FromUInt32((uint)m_ooxmlId++); string atomLabelName = "AtomLabel" + atomLabelId; Int64Value width = OoXmlHelper.ScaleCsTtfToEmu(alc.Character.Width); Int64Value height = OoXmlHelper.ScaleCsTtfToEmu(alc.Character.Height); if (alc.IsSubScript) { width = OoXmlHelper.ScaleCsTtfSubScriptToEmu(alc.Character.Width); height = OoXmlHelper.ScaleCsTtfSubScriptToEmu(alc.Character.Height); } Int64Value top = OoXmlHelper.ScaleCmlToEmu(characterPosition.Y); Int64Value left = OoXmlHelper.ScaleCmlToEmu(characterPosition.X); // Set variable true to show bounding box of (every) character if (m_options.ShowCharacterBoundingBoxes) { Rect boundingBox = new Rect(new Point(left, top), new Size(width, height)); DrawCharacterBox(wordprocessingGroup1, boundingBox, "00ff00", 10); } Wps.WordprocessingShape wordprocessingShape10 = new Wps.WordprocessingShape(); Wps.NonVisualDrawingProperties nonVisualDrawingProperties10 = new Wps.NonVisualDrawingProperties() { Id = atomLabelId, Name = atomLabelName }; Wps.NonVisualDrawingShapeProperties nonVisualDrawingShapeProperties10 = new Wps.NonVisualDrawingShapeProperties(); Wps.ShapeProperties shapeProperties10 = new Wps.ShapeProperties(); A.Transform2D transform2D10 = new A.Transform2D(); A.Offset offset11 = new A.Offset() { X = left, Y = top }; A.Extents extents11 = new A.Extents() { Cx = width, Cy = height }; transform2D10.Append(offset11); transform2D10.Append(extents11); A.CustomGeometry customGeometry10 = new A.CustomGeometry(); A.AdjustValueList adjustValueList10 = new A.AdjustValueList(); A.Rectangle rectangle10 = new A.Rectangle() { Left = "l", Top = "t", Right = "r", Bottom = "b" }; A.PathList pathList10 = new A.PathList(); A.Path path10 = new A.Path() { Width = width, Height = height }; foreach (TtfContour contour in alc.Character.Contours) { int i = 0; while (i < contour.Points.Count) { TtfPoint thisPoint = contour.Points[i]; TtfPoint nextPoint = null; if (i < contour.Points.Count - 1) { nextPoint = contour.Points[i + 1]; } switch (thisPoint.Type) { case TtfPoint.PointType.Start: A.MoveTo moveTo1 = new A.MoveTo(); if (alc.IsSubScript) { A.Point point1 = new A.Point() { X = OoXmlHelper.ScaleCsTtfSubScriptToEmu(thisPoint.X - alc.Character.OriginX).ToString(), Y = OoXmlHelper.ScaleCsTtfSubScriptToEmu(alc.Character.Height + thisPoint.Y - (alc.Character.Height + alc.Character.OriginY)).ToString() }; moveTo1.Append(point1); path10.Append(moveTo1); } else { A.Point point1 = new A.Point() { X = OoXmlHelper.ScaleCsTtfToEmu(thisPoint.X - alc.Character.OriginX).ToString(), Y = OoXmlHelper.ScaleCsTtfToEmu(alc.Character.Height + thisPoint.Y - (alc.Character.Height + alc.Character.OriginY)).ToString() }; moveTo1.Append(point1); path10.Append(moveTo1); } i++; break; case TtfPoint.PointType.Line: A.LineTo lineTo1 = new A.LineTo(); if (alc.IsSubScript) { A.Point point2 = new A.Point() { X = OoXmlHelper.ScaleCsTtfSubScriptToEmu(thisPoint.X - alc.Character.OriginX).ToString(), Y = OoXmlHelper.ScaleCsTtfSubScriptToEmu(alc.Character.Height + thisPoint.Y - (alc.Character.Height + alc.Character.OriginY)).ToString() }; lineTo1.Append(point2); path10.Append(lineTo1); } else { A.Point point2 = new A.Point() { X = OoXmlHelper.ScaleCsTtfToEmu(thisPoint.X - alc.Character.OriginX).ToString(), Y = OoXmlHelper.ScaleCsTtfToEmu(alc.Character.Height + thisPoint.Y - (alc.Character.Height + alc.Character.OriginY)).ToString() }; lineTo1.Append(point2); path10.Append(lineTo1); } i++; break; case TtfPoint.PointType.CurveOff: A.QuadraticBezierCurveTo quadraticBezierCurveTo13 = new A.QuadraticBezierCurveTo(); if (alc.IsSubScript) { A.Point point3 = new A.Point() { X = OoXmlHelper.ScaleCsTtfSubScriptToEmu(thisPoint.X - alc.Character.OriginX).ToString(), Y = OoXmlHelper.ScaleCsTtfSubScriptToEmu(alc.Character.Height + thisPoint.Y - (alc.Character.Height + alc.Character.OriginY)).ToString() }; A.Point point4 = new A.Point() { X = OoXmlHelper.ScaleCsTtfSubScriptToEmu(nextPoint.X - alc.Character.OriginX).ToString(), Y = OoXmlHelper.ScaleCsTtfSubScriptToEmu(alc.Character.Height + nextPoint.Y - (alc.Character.Height + alc.Character.OriginY)).ToString() }; quadraticBezierCurveTo13.Append(point3); quadraticBezierCurveTo13.Append(point4); path10.Append(quadraticBezierCurveTo13); } else { A.Point point3 = new A.Point() { X = OoXmlHelper.ScaleCsTtfToEmu(thisPoint.X - alc.Character.OriginX).ToString(), Y = OoXmlHelper.ScaleCsTtfToEmu(alc.Character.Height + thisPoint.Y - (alc.Character.Height + alc.Character.OriginY)).ToString() }; A.Point point4 = new A.Point() { X = OoXmlHelper.ScaleCsTtfToEmu(nextPoint.X - alc.Character.OriginX).ToString(), Y = OoXmlHelper.ScaleCsTtfToEmu(alc.Character.Height + nextPoint.Y - (alc.Character.Height + alc.Character.OriginY)).ToString() }; quadraticBezierCurveTo13.Append(point3); quadraticBezierCurveTo13.Append(point4); path10.Append(quadraticBezierCurveTo13); } i++; i++; break; case TtfPoint.PointType.CurveOn: // Should never get here ! i++; break; } } A.CloseShapePath closeShapePath1 = new A.CloseShapePath(); path10.Append(closeShapePath1); } pathList10.Append(path10); customGeometry10.Append(adjustValueList10); customGeometry10.Append(rectangle10); customGeometry10.Append(pathList10); A.SolidFill solidFill10 = new A.SolidFill(); // Set Colour A.RgbColorModelHex rgbColorModelHex10 = new A.RgbColorModelHex() { Val = alc.Colour }; A.Alpha alpha10 = new A.Alpha() { Val = new Int32Value() { InnerText = "100%" } }; rgbColorModelHex10.Append(alpha10); solidFill10.Append(rgbColorModelHex10); shapeProperties10.Append(transform2D10); shapeProperties10.Append(customGeometry10); shapeProperties10.Append(solidFill10); Wps.ShapeStyle shapeStyle10 = new Wps.ShapeStyle(); A.LineReference lineReference10 = new A.LineReference() { Index = (UInt32Value)0U }; A.FillReference fillReference10 = new A.FillReference() { Index = (UInt32Value)0U }; A.EffectReference effectReference10 = new A.EffectReference() { Index = (UInt32Value)0U }; A.FontReference fontReference10 = new A.FontReference() { Index = A.FontCollectionIndexValues.Minor }; shapeStyle10.Append(lineReference10); shapeStyle10.Append(fillReference10); shapeStyle10.Append(effectReference10); shapeStyle10.Append(fontReference10); Wps.TextBodyProperties textBodyProperties10 = new Wps.TextBodyProperties(); wordprocessingShape10.Append(nonVisualDrawingProperties10); wordprocessingShape10.Append(nonVisualDrawingShapeProperties10); wordprocessingShape10.Append(shapeProperties10); wordprocessingShape10.Append(shapeStyle10); wordprocessingShape10.Append(textBodyProperties10); wordprocessingGroup1.Append(wordprocessingShape10); }
//public static void InsertPicture(string docFile, string imageFile) //{ // using (WordprocessingDocument wordprocessingDocument = WordprocessingDocument.Open(docFile, isEditable: true)) // { // MainDocumentPart mainPart = wordprocessingDocument.MainDocumentPart; // ImagePart imagePart = mainPart.AddImagePart(ImagePartType.Jpeg); // using (FileStream stream = new FileStream(imageFile, FileMode.Open)) // { // imagePart.FeedData(stream); // } // AddImageToBody(wordprocessingDocument, mainPart.GetIdOfPart(imagePart)); // // Define the reference of the image. // var element = // new Drawing( // new DW.Inline( // new DW.Extent() { Cx = 990000L, Cy = 792000L }, // new DW.EffectExtent() // { // LeftEdge = 0L, // TopEdge = 0L, // RightEdge = 0L, // BottomEdge = 0L // }, // new DW.DocProperties() // { // Id = (UInt32Value)1U, // Name = "Picture 1" // }, // new DW.NonVisualGraphicFrameDrawingProperties( // new A.GraphicFrameLocks() { NoChangeAspect = true }), // new A.Graphic( // new A.GraphicData( // new PIC.Picture( // new PIC.NonVisualPictureProperties( // new PIC.NonVisualDrawingProperties() // { // Id = (UInt32Value)0U, // Name = "New Bitmap Image.jpg" // }, // new PIC.NonVisualPictureDrawingProperties()), // new PIC.BlipFill( // new A.Blip( // new A.BlipExtensionList( // new A.BlipExtension() // { Uri = "{28A0092B-C50C-407E-A947-70E740481C1C}" }) // ) // { // Embed = relationshipId, // CompressionState = A.BlipCompressionValues.Print // }, // new A.Stretch( // new A.FillRectangle())), // new PIC.ShapeProperties( // new A.Transform2D( // new A.Offset() { X = 0L, Y = 0L }, // new A.Extents() { Cx = 990000L, Cy = 792000L }), // new A.PresetGeometry( // new A.AdjustValueList() // ) // { Preset = A.ShapeTypeValues.Rectangle })) // ) // { Uri = "http://schemas.openxmlformats.org/drawingml/2006/picture" }) // ) // { // DistanceFromTop = (UInt32Value)0U, // DistanceFromBottom = (UInt32Value)0U, // DistanceFromLeft = (UInt32Value)0U, // DistanceFromRight = (UInt32Value)0U, // EditId = "50D07946" // }); // // Append the reference to the body. The element should be in // // a DocumentFormat.OpenXml.Wordprocessing.Run. // wordDoc.MainDocumentPart.Document.Body.AppendChild(new Paragraph(new Run(element))); // } //} public static void InsertAPicture(string documentFile, string imageFile, uint id, string name, Int64Value cx, Int64Value cy) { SetDirectory(); using (WordprocessingDocument wordprocessingDocument = WordprocessingDocument.Open(zPath.Combine(_directory, documentFile), true)) { MainDocumentPart mainPart = wordprocessingDocument.MainDocumentPart; ImagePart imagePart = mainPart.AddImagePart(ImagePartType.Jpeg); using (FileStream stream = new FileStream(imageFile, FileMode.Open)) { imagePart.FeedData(stream); } AddImageToBody(wordprocessingDocument, mainPart.GetIdOfPart(imagePart), id, name, cx, cy); } }
/// <summary> /// Scales a CS TTF SubScript X or Y co-ordinate to DrawingML Units (EMU) /// </summary> public static Int64Value ScaleCsTtfSubScriptToEmu(double XorY) { double scaled = XorY * EMUS_PER_CS_TTF_POINT_SUBSCRIPT; return(Int64Value.FromInt64((long)scaled)); }
private static DataValue ConvertInt64(Int64Value int64Value, DataType dataType, bool truncate) { switch (dataType) { case DataType.DataType_String: { return new StringValue(int64Value.Int64.ToString()); } case DataType.DataType_Single: { long l = int64Value.Int64; try { float f = Convert.ToSingle(l); return new SingleValue(f); } catch (OverflowException) { if (l > float.MaxValue) return new SingleValue(float.MaxValue); else if (l < float.MinValue) return new SingleValue(float.MinValue); else return new SingleValue((float)l); } } case DataType.DataType_Double: { long l = int64Value.Int64; try { double d = Convert.ToDouble(l); return new DoubleValue(d); } catch (OverflowException) { if (l > double.MaxValue) return new DoubleValue(double.MaxValue); else if (l < double.MinValue) return new DoubleValue(double.MinValue); else return new DoubleValue((double)l); } } case DataType.DataType_Decimal: { if (truncate) return new DecimalValue(Convert.ToDouble(int64Value.Int64)); else return null; } case DataType.DataType_Int16: { long l = int64Value.Int64; try { short d = Convert.ToInt16(l); return new Int16Value(d); } catch (OverflowException) { if (l > short.MaxValue) return new Int16Value(short.MaxValue); else if (l < short.MinValue) return new Int16Value(short.MinValue); else return new Int16Value((short)l); } } case DataType.DataType_Int32: { long l = int64Value.Int64; try { int d = Convert.ToInt32(l); return new Int32Value(d); } catch (OverflowException) { if (l > int.MaxValue) return new Int32Value(int.MaxValue); else if (l < int.MinValue) return new Int32Value(int.MinValue); else return new Int32Value((int)l); } } default: return null; } }
private static void AddSignatureToParagraph(WordprocessingDocument wordDoc, string relationshipId, Int64Value cx, Int64Value cy, string tagToReplace) { WriteDebugConsoleLogEntry(new LogEntry(2, "ReportHelper", "AddImageToBody called")); // Define the reference of the image. var element = new Drawing( new DW.Inline( new DW.Extent() { Cx = cx, Cy = cy }, new DW.EffectExtent() { LeftEdge = 0L, TopEdge = 0L, RightEdge = 0L, BottomEdge = 0L }, new DW.DocProperties() { Id = (UInt32Value)1U, Name = "Picture" }, new DW.NonVisualGraphicFrameDrawingProperties( new A.GraphicFrameLocks() { NoChangeAspect = true }), new A.Graphic( new A.GraphicData( new PIC.Picture( new PIC.NonVisualPictureProperties( new PIC.NonVisualDrawingProperties() { Id = (UInt32Value)0U, Name = "New Bitmap Image.jpg" }, new PIC.NonVisualPictureDrawingProperties()), new PIC.BlipFill( new A.Blip( new A.BlipExtensionList( new A.BlipExtension() { Uri = "{28A0092B-C50C-407E-A947-70E740481C1C}" }) ) { Embed = relationshipId, CompressionState = A.BlipCompressionValues.Print }, new A.Stretch( new A.FillRectangle())), new PIC.ShapeProperties( new A.Transform2D( new A.Offset() { X = 0L, Y = 0L }, new A.Extents() { Cx = 990000L, Cy = 792000L }), new A.PresetGeometry( new A.AdjustValueList() ) { Preset = A.ShapeTypeValues.Rectangle })) ) { Uri = "http://schemas.openxmlformats.org/drawingml/2006/picture" }) ) { DistanceFromTop = (UInt32Value)0U, DistanceFromBottom = (UInt32Value)0U, DistanceFromLeft = (UInt32Value)0U, DistanceFromRight = (UInt32Value)0U, EditId = "50D07946" }); var tagNode = wordDoc.MainDocumentPart.Document.Body.Elements <Paragraph>().FirstOrDefault(f => f.InnerText.Contains(tagToReplace)); if (tagNode != null) { tagNode.InsertBeforeSelf(new Paragraph(new Run(element))); tagNode.Remove(); } }
public void Bug520719() { // the following test should pass without Assert() in debug version. var int8 = new SByteValue(); int8.InnerText = "+10"; Assert.Equal(10, int8.Value); Assert.Equal("+10", int8.InnerText); var int16 = new Int16Value(); int16.InnerText = "+10"; Assert.Equal(10, int16.Value); Assert.Equal("+10", int16.InnerText); var int32 = new Int32Value(); int32.InnerText = "+10"; Assert.Equal(10, int32.Value); Assert.Equal("+10", int32.InnerText); var int64 = new Int64Value(); int64.InnerText = "+10"; Assert.Equal(10, int64.Value); Assert.Equal("+10", int64.InnerText); var integer = new IntegerValue(); integer.InnerText = "+10"; Assert.Equal(10, integer.Value); Assert.Equal("+10", integer.InnerText); var dec = new DecimalValue(); dec.InnerText = "+10"; Assert.Equal(10, dec.Value); Assert.Equal("+10", dec.InnerText); var single = new SingleValue(); single.InnerText = "+10"; Assert.Equal(10, single.Value); Assert.Equal("+10", single.InnerText); var dble = new DoubleValue(); dble.InnerText = "+10"; Assert.Equal(10, dble.Value); Assert.Equal("+10", dble.InnerText); }
/// <summary> /// Scales a CML X or Y co-ordinate to DrawingML Units (EMU) /// </summary> /// <param name="XorY"></param> /// <returns></returns> public static Int64Value ScaleCmlToEmu(double XorY) { double scaled = XorY * EMUS_PER_CML_POINT; return(Int64Value.FromInt64((long)scaled)); }
internal static OpenXmlSimpleType[] CreatePossibleMembers(UnionValueRestriction unionValueRestriction) { OpenXmlSimpleType[] simpleValues = new OpenXmlSimpleType[unionValueRestriction.UnionTypes.Length]; switch (unionValueRestriction.UnionId) { // ST_AnimationDgmBuildType case 25: simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Drawing.AnimationBuildValues>(); simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Drawing.AnimationDiagramOnlyBuildValues>(); break; // ST_AnimationChartBuildType case 27: simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Drawing.AnimationBuildValues>(); simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Drawing.AnimationChartOnlyBuildValues>(); break; // ST_AdjCoordinate case 45: simpleValues[0] = new Int64Value(); simpleValues[1] = new StringValue(); break; // ST_AdjAngle case 46: simpleValues[0] = new Int32Value(); simpleValues[1] = new StringValue(); break; // ST_LayoutShapeType case 145: simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Drawing.ShapeTypeValues>(); simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.OutputShapeValues>(); break; // ST_ParameterVal case 183: simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.HorizontalAlignmentValues>(); simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.VerticalAlignmentValues>(); simpleValues[2] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ChildDirectionValues>(); simpleValues[3] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ChildAlignmentValues>(); simpleValues[4] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.SecondaryChildAlignmentValues>(); simpleValues[5] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.LinearDirectionValues>(); simpleValues[6] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.SecondaryLinearDirectionValues>(); simpleValues[7] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.StartingElementValues>(); simpleValues[8] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.BendPointValues>(); simpleValues[9] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ConnectorRoutingValues>(); simpleValues[10] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ArrowheadStyleValues>(); simpleValues[11] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ConnectorDimensionValues>(); simpleValues[12] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.RotationPathValues>(); simpleValues[13] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.CenterShapeMappingValues>(); simpleValues[14] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.NodeHorizontalAlignmentValues>(); simpleValues[15] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.NodeVerticalAlignmentValues>(); simpleValues[16] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.FallbackDimensionValues>(); simpleValues[17] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.TextDirectionValues>(); simpleValues[18] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.PyramidAccentPositionValues>(); simpleValues[19] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.PyramidAccentTextMarginValues>(); simpleValues[20] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.TextBlockDirectionValues>(); simpleValues[21] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.TextAnchorHorizontalValues>(); simpleValues[22] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.TextAnchorVerticalValues>(); simpleValues[23] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.TextAlignmentValues>(); simpleValues[24] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.AutoTextRotationValues>(); simpleValues[25] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.GrowDirectionValues>(); simpleValues[26] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.FlowDirectionValues>(); simpleValues[27] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ContinueDirectionValues>(); simpleValues[28] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.BreakpointValues>(); simpleValues[29] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.OffsetValues>(); simpleValues[30] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.HierarchyAlignmentValues>(); simpleValues[31] = new Int32Value(); simpleValues[32] = new DoubleValue(); simpleValues[33] = new BooleanValue(); simpleValues[34] = new StringValue(); simpleValues[35] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ConnectorPointValues>(); break; // ST_ModelId case 184: simpleValues[0] = new Int32Value(); simpleValues[1] = new StringValue(); break; // ST_FunctionValue case 207: simpleValues[0] = new Int32Value(); simpleValues[1] = new BooleanValue(); simpleValues[2] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.DirectionValues>(); simpleValues[3] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.HierarchyBranchStyleValues>(); simpleValues[4] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.AnimateOneByOneValues>(); simpleValues[5] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.AnimationLevelStringValues>(); simpleValues[6] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ResizeHandlesStringValues>(); break; // ST_FunctionArgument case 209: simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.VariableValues>(); break; // ST_NonZeroDecimalNumber case 368: simpleValues[0] = new Int32Value(); simpleValues[1] = new Int32Value(); break; // ST_MarkupId case 375: simpleValues[0] = new Int32Value(); simpleValues[1] = new Int32Value(); break; // ST_HexColor case 404: simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Wordprocessing.AutomaticColorValues>(); simpleValues[1] = new HexBinaryValue(); break; // ST_DecimalNumberOrPercent case 507: simpleValues[0] = new StringValue(); simpleValues[1] = new Int32Value(); break; // ST_SignedHpsMeasure_O14 case 525: simpleValues[0] = new IntegerValue(); simpleValues[1] = new StringValue(); break; // ST_HpsMeasure_O14 case 528: simpleValues[0] = new UInt32Value(); simpleValues[1] = new StringValue(); break; // ST_SignedTwipsMeasure_O14 case 531: simpleValues[0] = new IntegerValue(); simpleValues[1] = new StringValue(); break; // ST_TwipsMeasure_O14 case 534: simpleValues[0] = new UInt32Value(); simpleValues[1] = new StringValue(); break; // ST_TransitionEightDirectionType case 544: simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Presentation.TransitionSlideDirectionValues>(); simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Presentation.TransitionCornerDirectionValues>(); break; // ST_TLTimeAnimateValueTime case 561: simpleValues[0] = new Int32Value(); simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Presentation.IndefiniteTimeDeclarationValues>(); break; // ST_TLTime_O12 case 603: simpleValues[0] = new UInt32Value(); simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Presentation.IndefiniteTimeDeclarationValues>(); break; // ST_TLTime_O14 case 604: simpleValues[0] = new StringValue(); simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Presentation.IndefiniteTimeDeclarationValues>(); break; // ST_PublishDate case 689: simpleValues[0] = new DateTimeValue(); simpleValues[1] = new DateTimeValue(); simpleValues[2] = new StringValue(); break; // ST_ChannelDataPoint case 697: simpleValues[0] = new DecimalValue(); simpleValues[1] = new BooleanValue(); break; // ST_ChannelPropertyName case 701: simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardChannelPropertyNameValues>(); simpleValues[1] = new StringValue(); break; // ST_BrushPropertyName case 704: simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardBrushPropertyNameValues>(); simpleValues[1] = new StringValue(); break; // ST_ChannelName case 707: simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardChannelNameValues>(); simpleValues[1] = new StringValue(); break; // ST_Units case 719: simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardLengthUnitsValues>(); simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardPerLengthUnitsValues>(); simpleValues[2] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardTimeUnitsValues>(); simpleValues[3] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardPerTimeUnitsValues>(); simpleValues[4] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardMassForceUnitsValues>(); simpleValues[5] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardPerMassForceUnitsValues>(); simpleValues[6] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardAngleUnitsValues>(); simpleValues[7] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardPerAngleUnitsValues>(); simpleValues[8] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardOtherUnitsValues>(); simpleValues[9] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardPerOtherUnitsValues>(); simpleValues[10] = new StringValue(); break; // ST_BrushPropertyValue case 732: simpleValues[0] = new DecimalValue(); simpleValues[1] = new BooleanValue(); simpleValues[2] = new EnumValue<DocumentFormat.OpenXml.InkML.PenTipShapeValues>(); simpleValues[3] = new EnumValue<DocumentFormat.OpenXml.InkML.RasterOperationValues>(); simpleValues[4] = new StringValue(); break; // ST_Ref case 746: simpleValues[0] = new StringValue(); simpleValues[1] = new UInt32Value(); break; // ST_CtxNodeType case 747: simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Office2010.Ink.KnownContextNodeTypeValues>(); simpleValues[1] = new StringValue(); break; // ST_SemanticType case 750: simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Office2010.Ink.KnownSemanticTypeValues>(); simpleValues[1] = new UInt32Value(); break; // ST_PointsOrInt case 753: simpleValues[0] = new ListValue<StringValue>(); simpleValues[1] = new Int32Value(); break; default: Debug.Assert(false); break; } Debug.Assert(simpleValues.Length > 0); return simpleValues; }
// Return a String representation of JSValue. It is equivalent to JavaScript String(value) result. public string AsJSString() { StringBuilder WriteValue(StringBuilder sb, JSValue node) { switch (node.Type) { case JSValueType.Null: return(sb.Append(JSConverter.NullString)); case JSValueType.Object: return(sb.Append(JSConverter.ObjectString)); case JSValueType.Array: { bool start = true; foreach (var item in node.ArrayValue) { if (start) { start = false; } else { sb.Append(','); } WriteValue(sb, item); } return(sb); } case JSValueType.String: return(sb.Append(node.StringValue)); case JSValueType.Boolean: return(sb.Append(JSConverter.ToJSString(node.BooleanValue))); case JSValueType.Int64: return(sb.Append(node.Int64Value)); case JSValueType.Double: return(sb.Append(JSConverter.ToJSString(node.DoubleValue))); default: return(sb); } } switch (Type) { case JSValueType.Null: return(JSConverter.NullString); case JSValueType.Object: return(JSConverter.ObjectString); case JSValueType.Array: { StringBuilder sb = new StringBuilder(); WriteValue(sb, this); return(sb.ToString()); } case JSValueType.String: return(StringValue); case JSValueType.Boolean: return(JSConverter.ToJSString(BooleanValue)); case JSValueType.Int64: return(Int64Value.ToString()); case JSValueType.Double: return(JSConverter.ToJSString(DoubleValue)); default: return(""); } }
private void Prepare(PropertyValueCollection propVals) { propVals.Clear(); currentValues.Clear(); // I do not trust the long-term stability of the PropertyValueCollection // // So what we do is load it up once with LiteralValue references and manipulate these // outside of the collection (via a cached dictionary). We cache everything from the wrapper API // that can be cached in the managed world so that we only have minimal contact with it // Omit read-only properties using (FdoFeatureService service = _conn.CreateFeatureService()) { ClassDefinition c = service.GetClassByName(this.ClassName); foreach (PropertyDefinition p in c.Properties) { string name = p.Name; PropertyValue pv = new PropertyValue(name, null); if (p.PropertyType == PropertyType.PropertyType_DataProperty) { DataPropertyDefinition d = p as DataPropertyDefinition; if (!d.ReadOnly && !d.IsAutoGenerated) { DataValue dv = null; switch (d.DataType) { case DataType.DataType_BLOB: dv = new BLOBValue(); break; case DataType.DataType_Boolean: dv = new BooleanValue(); break; case DataType.DataType_Byte: dv = new ByteValue(); break; case DataType.DataType_CLOB: dv = new CLOBValue(); break; case DataType.DataType_DateTime: dv = new DateTimeValue(); break; case DataType.DataType_Decimal: dv = new DecimalValue(); break; case DataType.DataType_Double: dv = new DoubleValue(); break; case DataType.DataType_Int16: dv = new Int16Value(); break; case DataType.DataType_Int32: dv = new Int32Value(); break; case DataType.DataType_Int64: dv = new Int64Value(); break; case DataType.DataType_Single: dv = new SingleValue(); break; case DataType.DataType_String: dv = new StringValue(); break; } if (dv != null) { pv.Value = dv; propVals.Add(pv); } } } else if (p.PropertyType == PropertyType.PropertyType_GeometricProperty) { GeometricPropertyDefinition g = p as GeometricPropertyDefinition; if (!g.ReadOnly) { GeometryValue gv = new GeometryValue(); pv.Value = gv; propVals.Add(pv); } } } c.Dispose(); } //Load property values into temp dictionary foreach (PropertyValue p in propVals) { currentValues[p.Name.Name] = p.Value as LiteralValue; } if (propertySnapshot == null) { propertySnapshot = new List<string>(); foreach (PropertyValue p in propVals) { propertySnapshot.Add(p.Name.Name); } } }
public override Round GetRoundInformation(Int64Value input) => TryToGetRoundInformation(input.Value, out var round) ? round : new Round();