private void DrawDashedLine(Wpg.WordprocessingGroup wordprocessingGroup, Rect cmlExtents, Point bondStart, Point bondEnd, string colour = "000000") { UInt32Value id = UInt32Value.FromUInt32((uint)m_ooxmlId++); string bondLineName = "DashedBondLine" + id; Int64Value width = OoXmlHelper.ScaleCmlToEmu(cmlExtents.Width); Int64Value height = OoXmlHelper.ScaleCmlToEmu(cmlExtents.Height); Int64Value top = OoXmlHelper.ScaleCmlToEmu(cmlExtents.Top); Int64Value left = OoXmlHelper.ScaleCmlToEmu(cmlExtents.Left); Wps.WordprocessingShape shape = new Wps.WordprocessingShape(); Wps.NonVisualDrawingProperties nonVisualDrawingProperties = new Wps.NonVisualDrawingProperties() { Id = id, Name = bondLineName }; Wps.NonVisualDrawingShapeProperties nonVisualDrawingShapeProperties = new Wps.NonVisualDrawingShapeProperties(); Wps.ShapeProperties shapeProperties = new Wps.ShapeProperties(); A.Transform2D transform2D = new A.Transform2D(); A.Offset offset = new A.Offset { X = left, Y = top }; A.Extents extents = new A.Extents { Cx = width, Cy = height }; transform2D.Append(offset); transform2D.Append(extents); A.CustomGeometry customGeometry = new A.CustomGeometry(); A.AdjustValueList adjustValueList = new A.AdjustValueList(); A.Rectangle rectangle = new A.Rectangle { Left = "l", Top = "t", Right = "r", Bottom = "b" }; A.PathList pathList = new A.PathList(); A.Path path = new A.Path { Width = width, Height = height }; A.MoveTo moveTo = new A.MoveTo(); A.Point point1 = new A.Point { X = OoXmlHelper.ScaleCmlToEmu(bondStart.X).ToString(), Y = OoXmlHelper.ScaleCmlToEmu(bondStart.Y).ToString() }; moveTo.Append(point1); A.LineTo lineTo = new A.LineTo(); A.Point point2 = new A.Point { X = OoXmlHelper.ScaleCmlToEmu(bondEnd.X).ToString(), Y = OoXmlHelper.ScaleCmlToEmu(bondEnd.Y).ToString() }; lineTo.Append(point2); path.Append(moveTo); path.Append(lineTo); pathList.Append(path); customGeometry.Append(adjustValueList); customGeometry.Append(rectangle); customGeometry.Append(pathList); A.Outline outline = new A.Outline { Width = OoXmlHelper.ACS_LINE_WIDTH_EMUS, CapType = A.LineCapValues.Round }; A.SolidFill solidFill = new A.SolidFill(); A.PresetDash presetDash = new A.PresetDash() { Val = A.PresetLineDashValues.SystemDash }; A.RgbColorModelHex rgbColorModelHex = new A.RgbColorModelHex { Val = colour }; solidFill.Append(rgbColorModelHex); outline.Append(solidFill); outline.Append(presetDash); shapeProperties.Append(transform2D); shapeProperties.Append(customGeometry); shapeProperties.Append(outline); OoXmlHelper.AppendShapeStyle(shape, nonVisualDrawingProperties, nonVisualDrawingShapeProperties, shapeProperties); wordprocessingGroup.Append(shape); }
// Generates content of themePart1. private void GenerateThemePart1Content(ThemePart themePart1) { A.Theme theme1 = new A.Theme() { Name = "Tema de Office" }; theme1.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main"); A.ThemeElements themeElements1 = new A.ThemeElements(); A.ColorScheme colorScheme1 = new A.ColorScheme() { Name = "Office" }; A.Dark1Color dark1Color1 = new A.Dark1Color(); A.SystemColor systemColor1 = new A.SystemColor() { Val = A.SystemColorValues.WindowText, LastColor = "000000" }; dark1Color1.Append(systemColor1); A.Light1Color light1Color1 = new A.Light1Color(); A.SystemColor systemColor2 = new A.SystemColor() { Val = A.SystemColorValues.Window, LastColor = "FFFFFF" }; light1Color1.Append(systemColor2); A.Dark2Color dark2Color1 = new A.Dark2Color(); A.RgbColorModelHex rgbColorModelHex1 = new A.RgbColorModelHex() { Val = "1F497D" }; dark2Color1.Append(rgbColorModelHex1); A.Light2Color light2Color1 = new A.Light2Color(); A.RgbColorModelHex rgbColorModelHex2 = new A.RgbColorModelHex() { Val = "EEECE1" }; light2Color1.Append(rgbColorModelHex2); A.Accent1Color accent1Color1 = new A.Accent1Color(); A.RgbColorModelHex rgbColorModelHex3 = new A.RgbColorModelHex() { Val = "4F81BD" }; accent1Color1.Append(rgbColorModelHex3); A.Accent2Color accent2Color1 = new A.Accent2Color(); A.RgbColorModelHex rgbColorModelHex4 = new A.RgbColorModelHex() { Val = "C0504D" }; accent2Color1.Append(rgbColorModelHex4); A.Accent3Color accent3Color1 = new A.Accent3Color(); A.RgbColorModelHex rgbColorModelHex5 = new A.RgbColorModelHex() { Val = "9BBB59" }; accent3Color1.Append(rgbColorModelHex5); A.Accent4Color accent4Color1 = new A.Accent4Color(); A.RgbColorModelHex rgbColorModelHex6 = new A.RgbColorModelHex() { Val = "8064A2" }; accent4Color1.Append(rgbColorModelHex6); A.Accent5Color accent5Color1 = new A.Accent5Color(); A.RgbColorModelHex rgbColorModelHex7 = new A.RgbColorModelHex() { Val = "4BACC6" }; accent5Color1.Append(rgbColorModelHex7); A.Accent6Color accent6Color1 = new A.Accent6Color(); A.RgbColorModelHex rgbColorModelHex8 = new A.RgbColorModelHex() { Val = "F79646" }; accent6Color1.Append(rgbColorModelHex8); A.Hyperlink hyperlink1 = new A.Hyperlink(); A.RgbColorModelHex rgbColorModelHex9 = new A.RgbColorModelHex() { Val = "0000FF" }; hyperlink1.Append(rgbColorModelHex9); A.FollowedHyperlinkColor followedHyperlinkColor1 = new A.FollowedHyperlinkColor(); A.RgbColorModelHex rgbColorModelHex10 = new A.RgbColorModelHex() { Val = "800080" }; followedHyperlinkColor1.Append(rgbColorModelHex10); colorScheme1.Append(dark1Color1); colorScheme1.Append(light1Color1); colorScheme1.Append(dark2Color1); colorScheme1.Append(light2Color1); colorScheme1.Append(accent1Color1); colorScheme1.Append(accent2Color1); colorScheme1.Append(accent3Color1); colorScheme1.Append(accent4Color1); colorScheme1.Append(accent5Color1); colorScheme1.Append(accent6Color1); colorScheme1.Append(hyperlink1); colorScheme1.Append(followedHyperlinkColor1); A.FontScheme fontScheme1 = new A.FontScheme() { Name = "Office" }; A.MajorFont majorFont1 = new A.MajorFont(); A.LatinFont latinFont1 = new A.LatinFont() { Typeface = "Cambria" }; A.EastAsianFont eastAsianFont1 = new A.EastAsianFont() { Typeface = "" }; A.ComplexScriptFont complexScriptFont1 = new A.ComplexScriptFont() { Typeface = "" }; A.SupplementalFont supplementalFont1 = new A.SupplementalFont() { Script = "Jpan", Typeface = "MS Pゴシック" }; A.SupplementalFont supplementalFont2 = new A.SupplementalFont() { Script = "Hang", Typeface = "맑은 고딕" }; A.SupplementalFont supplementalFont3 = new A.SupplementalFont() { Script = "Hans", Typeface = "宋体" }; A.SupplementalFont supplementalFont4 = new A.SupplementalFont() { Script = "Hant", Typeface = "新細明體" }; A.SupplementalFont supplementalFont5 = new A.SupplementalFont() { Script = "Arab", Typeface = "Times New Roman" }; A.SupplementalFont supplementalFont6 = new A.SupplementalFont() { Script = "Hebr", Typeface = "Times New Roman" }; A.SupplementalFont supplementalFont7 = new A.SupplementalFont() { Script = "Thai", Typeface = "Tahoma" }; A.SupplementalFont supplementalFont8 = new A.SupplementalFont() { Script = "Ethi", Typeface = "Nyala" }; A.SupplementalFont supplementalFont9 = new A.SupplementalFont() { Script = "Beng", Typeface = "Vrinda" }; A.SupplementalFont supplementalFont10 = new A.SupplementalFont() { Script = "Gujr", Typeface = "Shruti" }; A.SupplementalFont supplementalFont11 = new A.SupplementalFont() { Script = "Khmr", Typeface = "MoolBoran" }; A.SupplementalFont supplementalFont12 = new A.SupplementalFont() { Script = "Knda", Typeface = "Tunga" }; A.SupplementalFont supplementalFont13 = new A.SupplementalFont() { Script = "Guru", Typeface = "Raavi" }; A.SupplementalFont supplementalFont14 = new A.SupplementalFont() { Script = "Cans", Typeface = "Euphemia" }; A.SupplementalFont supplementalFont15 = new A.SupplementalFont() { Script = "Cher", Typeface = "Plantagenet Cherokee" }; A.SupplementalFont supplementalFont16 = new A.SupplementalFont() { Script = "Yiii", Typeface = "Microsoft Yi Baiti" }; A.SupplementalFont supplementalFont17 = new A.SupplementalFont() { Script = "Tibt", Typeface = "Microsoft Himalaya" }; A.SupplementalFont supplementalFont18 = new A.SupplementalFont() { Script = "Thaa", Typeface = "MV Boli" }; A.SupplementalFont supplementalFont19 = new A.SupplementalFont() { Script = "Deva", Typeface = "Mangal" }; A.SupplementalFont supplementalFont20 = new A.SupplementalFont() { Script = "Telu", Typeface = "Gautami" }; A.SupplementalFont supplementalFont21 = new A.SupplementalFont() { Script = "Taml", Typeface = "Latha" }; A.SupplementalFont supplementalFont22 = new A.SupplementalFont() { Script = "Syrc", Typeface = "Estrangelo Edessa" }; A.SupplementalFont supplementalFont23 = new A.SupplementalFont() { Script = "Orya", Typeface = "Kalinga" }; A.SupplementalFont supplementalFont24 = new A.SupplementalFont() { Script = "Mlym", Typeface = "Kartika" }; A.SupplementalFont supplementalFont25 = new A.SupplementalFont() { Script = "Laoo", Typeface = "DokChampa" }; A.SupplementalFont supplementalFont26 = new A.SupplementalFont() { Script = "Sinh", Typeface = "Iskoola Pota" }; A.SupplementalFont supplementalFont27 = new A.SupplementalFont() { Script = "Mong", Typeface = "Mongolian Baiti" }; A.SupplementalFont supplementalFont28 = new A.SupplementalFont() { Script = "Viet", Typeface = "Times New Roman" }; A.SupplementalFont supplementalFont29 = new A.SupplementalFont() { Script = "Uigh", Typeface = "Microsoft Uighur" }; majorFont1.Append(latinFont1); majorFont1.Append(eastAsianFont1); majorFont1.Append(complexScriptFont1); majorFont1.Append(supplementalFont1); majorFont1.Append(supplementalFont2); majorFont1.Append(supplementalFont3); majorFont1.Append(supplementalFont4); majorFont1.Append(supplementalFont5); majorFont1.Append(supplementalFont6); majorFont1.Append(supplementalFont7); majorFont1.Append(supplementalFont8); majorFont1.Append(supplementalFont9); majorFont1.Append(supplementalFont10); majorFont1.Append(supplementalFont11); majorFont1.Append(supplementalFont12); majorFont1.Append(supplementalFont13); majorFont1.Append(supplementalFont14); majorFont1.Append(supplementalFont15); majorFont1.Append(supplementalFont16); majorFont1.Append(supplementalFont17); majorFont1.Append(supplementalFont18); majorFont1.Append(supplementalFont19); majorFont1.Append(supplementalFont20); majorFont1.Append(supplementalFont21); majorFont1.Append(supplementalFont22); majorFont1.Append(supplementalFont23); majorFont1.Append(supplementalFont24); majorFont1.Append(supplementalFont25); majorFont1.Append(supplementalFont26); majorFont1.Append(supplementalFont27); majorFont1.Append(supplementalFont28); majorFont1.Append(supplementalFont29); A.MinorFont minorFont1 = new A.MinorFont(); A.LatinFont latinFont2 = new A.LatinFont() { Typeface = "Calibri" }; A.EastAsianFont eastAsianFont2 = new A.EastAsianFont() { Typeface = "" }; A.ComplexScriptFont complexScriptFont2 = new A.ComplexScriptFont() { Typeface = "" }; A.SupplementalFont supplementalFont30 = new A.SupplementalFont() { Script = "Jpan", Typeface = "MS Pゴシック" }; A.SupplementalFont supplementalFont31 = new A.SupplementalFont() { Script = "Hang", Typeface = "맑은 고딕" }; A.SupplementalFont supplementalFont32 = new A.SupplementalFont() { Script = "Hans", Typeface = "宋体" }; A.SupplementalFont supplementalFont33 = new A.SupplementalFont() { Script = "Hant", Typeface = "新細明體" }; A.SupplementalFont supplementalFont34 = new A.SupplementalFont() { Script = "Arab", Typeface = "Arial" }; A.SupplementalFont supplementalFont35 = new A.SupplementalFont() { Script = "Hebr", Typeface = "Arial" }; A.SupplementalFont supplementalFont36 = new A.SupplementalFont() { Script = "Thai", Typeface = "Tahoma" }; A.SupplementalFont supplementalFont37 = new A.SupplementalFont() { Script = "Ethi", Typeface = "Nyala" }; A.SupplementalFont supplementalFont38 = new A.SupplementalFont() { Script = "Beng", Typeface = "Vrinda" }; A.SupplementalFont supplementalFont39 = new A.SupplementalFont() { Script = "Gujr", Typeface = "Shruti" }; A.SupplementalFont supplementalFont40 = new A.SupplementalFont() { Script = "Khmr", Typeface = "DaunPenh" }; A.SupplementalFont supplementalFont41 = new A.SupplementalFont() { Script = "Knda", Typeface = "Tunga" }; A.SupplementalFont supplementalFont42 = new A.SupplementalFont() { Script = "Guru", Typeface = "Raavi" }; A.SupplementalFont supplementalFont43 = new A.SupplementalFont() { Script = "Cans", Typeface = "Euphemia" }; A.SupplementalFont supplementalFont44 = new A.SupplementalFont() { Script = "Cher", Typeface = "Plantagenet Cherokee" }; A.SupplementalFont supplementalFont45 = new A.SupplementalFont() { Script = "Yiii", Typeface = "Microsoft Yi Baiti" }; A.SupplementalFont supplementalFont46 = new A.SupplementalFont() { Script = "Tibt", Typeface = "Microsoft Himalaya" }; A.SupplementalFont supplementalFont47 = new A.SupplementalFont() { Script = "Thaa", Typeface = "MV Boli" }; A.SupplementalFont supplementalFont48 = new A.SupplementalFont() { Script = "Deva", Typeface = "Mangal" }; A.SupplementalFont supplementalFont49 = new A.SupplementalFont() { Script = "Telu", Typeface = "Gautami" }; A.SupplementalFont supplementalFont50 = new A.SupplementalFont() { Script = "Taml", Typeface = "Latha" }; A.SupplementalFont supplementalFont51 = new A.SupplementalFont() { Script = "Syrc", Typeface = "Estrangelo Edessa" }; A.SupplementalFont supplementalFont52 = new A.SupplementalFont() { Script = "Orya", Typeface = "Kalinga" }; A.SupplementalFont supplementalFont53 = new A.SupplementalFont() { Script = "Mlym", Typeface = "Kartika" }; A.SupplementalFont supplementalFont54 = new A.SupplementalFont() { Script = "Laoo", Typeface = "DokChampa" }; A.SupplementalFont supplementalFont55 = new A.SupplementalFont() { Script = "Sinh", Typeface = "Iskoola Pota" }; A.SupplementalFont supplementalFont56 = new A.SupplementalFont() { Script = "Mong", Typeface = "Mongolian Baiti" }; A.SupplementalFont supplementalFont57 = new A.SupplementalFont() { Script = "Viet", Typeface = "Arial" }; A.SupplementalFont supplementalFont58 = new A.SupplementalFont() { Script = "Uigh", Typeface = "Microsoft Uighur" }; minorFont1.Append(latinFont2); minorFont1.Append(eastAsianFont2); minorFont1.Append(complexScriptFont2); minorFont1.Append(supplementalFont30); minorFont1.Append(supplementalFont31); minorFont1.Append(supplementalFont32); minorFont1.Append(supplementalFont33); minorFont1.Append(supplementalFont34); minorFont1.Append(supplementalFont35); minorFont1.Append(supplementalFont36); minorFont1.Append(supplementalFont37); minorFont1.Append(supplementalFont38); minorFont1.Append(supplementalFont39); minorFont1.Append(supplementalFont40); minorFont1.Append(supplementalFont41); minorFont1.Append(supplementalFont42); minorFont1.Append(supplementalFont43); minorFont1.Append(supplementalFont44); minorFont1.Append(supplementalFont45); minorFont1.Append(supplementalFont46); minorFont1.Append(supplementalFont47); minorFont1.Append(supplementalFont48); minorFont1.Append(supplementalFont49); minorFont1.Append(supplementalFont50); minorFont1.Append(supplementalFont51); minorFont1.Append(supplementalFont52); minorFont1.Append(supplementalFont53); minorFont1.Append(supplementalFont54); minorFont1.Append(supplementalFont55); minorFont1.Append(supplementalFont56); minorFont1.Append(supplementalFont57); minorFont1.Append(supplementalFont58); fontScheme1.Append(majorFont1); fontScheme1.Append(minorFont1); A.FormatScheme formatScheme1 = new A.FormatScheme() { Name = "Office" }; A.FillStyleList fillStyleList1 = new A.FillStyleList(); A.SolidFill solidFill1 = new A.SolidFill(); A.SchemeColor schemeColor1 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; solidFill1.Append(schemeColor1); A.GradientFill gradientFill1 = new A.GradientFill() { RotateWithShape = true }; A.GradientStopList gradientStopList1 = new A.GradientStopList(); A.GradientStop gradientStop1 = new A.GradientStop() { Position = 0 }; A.SchemeColor schemeColor2 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; A.Tint tint1 = new A.Tint() { Val = 50000 }; A.SaturationModulation saturationModulation1 = new A.SaturationModulation() { Val = 300000 }; schemeColor2.Append(tint1); schemeColor2.Append(saturationModulation1); gradientStop1.Append(schemeColor2); A.GradientStop gradientStop2 = new A.GradientStop() { Position = 35000 }; A.SchemeColor schemeColor3 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; A.Tint tint2 = new A.Tint() { Val = 37000 }; A.SaturationModulation saturationModulation2 = new A.SaturationModulation() { Val = 300000 }; schemeColor3.Append(tint2); schemeColor3.Append(saturationModulation2); gradientStop2.Append(schemeColor3); A.GradientStop gradientStop3 = new A.GradientStop() { Position = 100000 }; A.SchemeColor schemeColor4 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; A.Tint tint3 = new A.Tint() { Val = 15000 }; A.SaturationModulation saturationModulation3 = new A.SaturationModulation() { Val = 350000 }; schemeColor4.Append(tint3); schemeColor4.Append(saturationModulation3); gradientStop3.Append(schemeColor4); gradientStopList1.Append(gradientStop1); gradientStopList1.Append(gradientStop2); gradientStopList1.Append(gradientStop3); A.LinearGradientFill linearGradientFill1 = new A.LinearGradientFill() { Angle = 16200000, Scaled = true }; gradientFill1.Append(gradientStopList1); gradientFill1.Append(linearGradientFill1); A.GradientFill gradientFill2 = new A.GradientFill() { RotateWithShape = true }; A.GradientStopList gradientStopList2 = new A.GradientStopList(); A.GradientStop gradientStop4 = new A.GradientStop() { Position = 0 }; A.SchemeColor schemeColor5 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; A.Shade shade1 = new A.Shade() { Val = 51000 }; A.SaturationModulation saturationModulation4 = new A.SaturationModulation() { Val = 130000 }; schemeColor5.Append(shade1); schemeColor5.Append(saturationModulation4); gradientStop4.Append(schemeColor5); A.GradientStop gradientStop5 = new A.GradientStop() { Position = 80000 }; A.SchemeColor schemeColor6 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; A.Shade shade2 = new A.Shade() { Val = 93000 }; A.SaturationModulation saturationModulation5 = new A.SaturationModulation() { Val = 130000 }; schemeColor6.Append(shade2); schemeColor6.Append(saturationModulation5); gradientStop5.Append(schemeColor6); A.GradientStop gradientStop6 = new A.GradientStop() { Position = 100000 }; A.SchemeColor schemeColor7 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; A.Shade shade3 = new A.Shade() { Val = 94000 }; A.SaturationModulation saturationModulation6 = new A.SaturationModulation() { Val = 135000 }; schemeColor7.Append(shade3); schemeColor7.Append(saturationModulation6); gradientStop6.Append(schemeColor7); gradientStopList2.Append(gradientStop4); gradientStopList2.Append(gradientStop5); gradientStopList2.Append(gradientStop6); A.LinearGradientFill linearGradientFill2 = new A.LinearGradientFill() { Angle = 16200000, Scaled = false }; gradientFill2.Append(gradientStopList2); gradientFill2.Append(linearGradientFill2); fillStyleList1.Append(solidFill1); fillStyleList1.Append(gradientFill1); fillStyleList1.Append(gradientFill2); A.LineStyleList lineStyleList1 = new A.LineStyleList(); A.Outline outline1 = new A.Outline() { Width = 9525, CapType = A.LineCapValues.Flat, CompoundLineType = A.CompoundLineValues.Single, Alignment = A.PenAlignmentValues.Center }; A.SolidFill solidFill2 = new A.SolidFill(); A.SchemeColor schemeColor8 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; A.Shade shade4 = new A.Shade() { Val = 95000 }; A.SaturationModulation saturationModulation7 = new A.SaturationModulation() { Val = 105000 }; schemeColor8.Append(shade4); schemeColor8.Append(saturationModulation7); solidFill2.Append(schemeColor8); A.PresetDash presetDash1 = new A.PresetDash() { Val = A.PresetLineDashValues.Solid }; outline1.Append(solidFill2); outline1.Append(presetDash1); A.Outline outline2 = new A.Outline() { Width = 25400, CapType = A.LineCapValues.Flat, CompoundLineType = A.CompoundLineValues.Single, Alignment = A.PenAlignmentValues.Center }; A.SolidFill solidFill3 = new A.SolidFill(); A.SchemeColor schemeColor9 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; solidFill3.Append(schemeColor9); A.PresetDash presetDash2 = new A.PresetDash() { Val = A.PresetLineDashValues.Solid }; outline2.Append(solidFill3); outline2.Append(presetDash2); A.Outline outline3 = new A.Outline() { Width = 38100, CapType = A.LineCapValues.Flat, CompoundLineType = A.CompoundLineValues.Single, Alignment = A.PenAlignmentValues.Center }; A.SolidFill solidFill4 = new A.SolidFill(); A.SchemeColor schemeColor10 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; solidFill4.Append(schemeColor10); A.PresetDash presetDash3 = new A.PresetDash() { Val = A.PresetLineDashValues.Solid }; outline3.Append(solidFill4); outline3.Append(presetDash3); lineStyleList1.Append(outline1); lineStyleList1.Append(outline2); lineStyleList1.Append(outline3); A.EffectStyleList effectStyleList1 = new A.EffectStyleList(); A.EffectStyle effectStyle1 = new A.EffectStyle(); A.EffectList effectList1 = new A.EffectList(); A.OuterShadow outerShadow1 = new A.OuterShadow() { BlurRadius = 40000L, Distance = 20000L, Direction = 5400000, RotateWithShape = false }; A.RgbColorModelHex rgbColorModelHex11 = new A.RgbColorModelHex() { Val = "000000" }; A.Alpha alpha1 = new A.Alpha() { Val = 38000 }; rgbColorModelHex11.Append(alpha1); outerShadow1.Append(rgbColorModelHex11); effectList1.Append(outerShadow1); effectStyle1.Append(effectList1); A.EffectStyle effectStyle2 = new A.EffectStyle(); A.EffectList effectList2 = new A.EffectList(); A.OuterShadow outerShadow2 = new A.OuterShadow() { BlurRadius = 40000L, Distance = 23000L, Direction = 5400000, RotateWithShape = false }; A.RgbColorModelHex rgbColorModelHex12 = new A.RgbColorModelHex() { Val = "000000" }; A.Alpha alpha2 = new A.Alpha() { Val = 35000 }; rgbColorModelHex12.Append(alpha2); outerShadow2.Append(rgbColorModelHex12); effectList2.Append(outerShadow2); effectStyle2.Append(effectList2); A.EffectStyle effectStyle3 = new A.EffectStyle(); A.EffectList effectList3 = new A.EffectList(); A.OuterShadow outerShadow3 = new A.OuterShadow() { BlurRadius = 40000L, Distance = 23000L, Direction = 5400000, RotateWithShape = false }; A.RgbColorModelHex rgbColorModelHex13 = new A.RgbColorModelHex() { Val = "000000" }; A.Alpha alpha3 = new A.Alpha() { Val = 35000 }; rgbColorModelHex13.Append(alpha3); outerShadow3.Append(rgbColorModelHex13); effectList3.Append(outerShadow3); A.Scene3DType scene3DType1 = new A.Scene3DType(); A.Camera camera1 = new A.Camera() { Preset = A.PresetCameraValues.OrthographicFront }; A.Rotation rotation1 = new A.Rotation() { Latitude = 0, Longitude = 0, Revolution = 0 }; camera1.Append(rotation1); A.LightRig lightRig1 = new A.LightRig() { Rig = A.LightRigValues.ThreePoints, Direction = A.LightRigDirectionValues.Top }; A.Rotation rotation2 = new A.Rotation() { Latitude = 0, Longitude = 0, Revolution = 1200000 }; lightRig1.Append(rotation2); scene3DType1.Append(camera1); scene3DType1.Append(lightRig1); A.Shape3DType shape3DType1 = new A.Shape3DType(); A.BevelTop bevelTop1 = new A.BevelTop() { Width = 63500L, Height = 25400L }; shape3DType1.Append(bevelTop1); effectStyle3.Append(effectList3); effectStyle3.Append(scene3DType1); effectStyle3.Append(shape3DType1); effectStyleList1.Append(effectStyle1); effectStyleList1.Append(effectStyle2); effectStyleList1.Append(effectStyle3); A.BackgroundFillStyleList backgroundFillStyleList1 = new A.BackgroundFillStyleList(); A.SolidFill solidFill5 = new A.SolidFill(); A.SchemeColor schemeColor11 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; solidFill5.Append(schemeColor11); A.GradientFill gradientFill3 = new A.GradientFill() { RotateWithShape = true }; A.GradientStopList gradientStopList3 = new A.GradientStopList(); A.GradientStop gradientStop7 = new A.GradientStop() { Position = 0 }; A.SchemeColor schemeColor12 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; A.Tint tint4 = new A.Tint() { Val = 40000 }; A.SaturationModulation saturationModulation8 = new A.SaturationModulation() { Val = 350000 }; schemeColor12.Append(tint4); schemeColor12.Append(saturationModulation8); gradientStop7.Append(schemeColor12); A.GradientStop gradientStop8 = new A.GradientStop() { Position = 40000 }; A.SchemeColor schemeColor13 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; A.Tint tint5 = new A.Tint() { Val = 45000 }; A.Shade shade5 = new A.Shade() { Val = 99000 }; A.SaturationModulation saturationModulation9 = new A.SaturationModulation() { Val = 350000 }; schemeColor13.Append(tint5); schemeColor13.Append(shade5); schemeColor13.Append(saturationModulation9); gradientStop8.Append(schemeColor13); A.GradientStop gradientStop9 = new A.GradientStop() { Position = 100000 }; A.SchemeColor schemeColor14 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; A.Shade shade6 = new A.Shade() { Val = 20000 }; A.SaturationModulation saturationModulation10 = new A.SaturationModulation() { Val = 255000 }; schemeColor14.Append(shade6); schemeColor14.Append(saturationModulation10); gradientStop9.Append(schemeColor14); gradientStopList3.Append(gradientStop7); gradientStopList3.Append(gradientStop8); gradientStopList3.Append(gradientStop9); A.PathGradientFill pathGradientFill1 = new A.PathGradientFill() { Path = A.PathShadeValues.Circle }; A.FillToRectangle fillToRectangle1 = new A.FillToRectangle() { Left = 50000, Top = -80000, Right = 50000, Bottom = 180000 }; pathGradientFill1.Append(fillToRectangle1); gradientFill3.Append(gradientStopList3); gradientFill3.Append(pathGradientFill1); A.GradientFill gradientFill4 = new A.GradientFill() { RotateWithShape = true }; A.GradientStopList gradientStopList4 = new A.GradientStopList(); A.GradientStop gradientStop10 = new A.GradientStop() { Position = 0 }; A.SchemeColor schemeColor15 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; A.Tint tint6 = new A.Tint() { Val = 80000 }; A.SaturationModulation saturationModulation11 = new A.SaturationModulation() { Val = 300000 }; schemeColor15.Append(tint6); schemeColor15.Append(saturationModulation11); gradientStop10.Append(schemeColor15); A.GradientStop gradientStop11 = new A.GradientStop() { Position = 100000 }; A.SchemeColor schemeColor16 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; A.Shade shade7 = new A.Shade() { Val = 30000 }; A.SaturationModulation saturationModulation12 = new A.SaturationModulation() { Val = 200000 }; schemeColor16.Append(shade7); schemeColor16.Append(saturationModulation12); gradientStop11.Append(schemeColor16); gradientStopList4.Append(gradientStop10); gradientStopList4.Append(gradientStop11); A.PathGradientFill pathGradientFill2 = new A.PathGradientFill() { Path = A.PathShadeValues.Circle }; A.FillToRectangle fillToRectangle2 = new A.FillToRectangle() { Left = 50000, Top = 50000, Right = 50000, Bottom = 50000 }; pathGradientFill2.Append(fillToRectangle2); gradientFill4.Append(gradientStopList4); gradientFill4.Append(pathGradientFill2); backgroundFillStyleList1.Append(solidFill5); backgroundFillStyleList1.Append(gradientFill3); backgroundFillStyleList1.Append(gradientFill4); formatScheme1.Append(fillStyleList1); formatScheme1.Append(lineStyleList1); formatScheme1.Append(effectStyleList1); formatScheme1.Append(backgroundFillStyleList1); themeElements1.Append(colorScheme1); themeElements1.Append(fontScheme1); themeElements1.Append(formatScheme1); A.ObjectDefaults objectDefaults1 = new A.ObjectDefaults(); A.ShapeDefault shapeDefault1 = new A.ShapeDefault(); A.ShapeProperties shapeProperties1 = new A.ShapeProperties() { BlackWhiteMode = A.BlackWhiteModeValues.Auto }; A.Transform2D transform2D1 = new A.Transform2D(); A.Offset offset1 = new A.Offset() { X = 0L, Y = 0L }; A.Extents extents1 = new A.Extents() { Cx = 1L, Cy = 1L }; transform2D1.Append(offset1); transform2D1.Append(extents1); A.CustomGeometry customGeometry1 = new A.CustomGeometry(); A.AdjustValueList adjustValueList1 = new A.AdjustValueList(); A.ShapeGuideList shapeGuideList1 = new A.ShapeGuideList(); A.AdjustHandleList adjustHandleList1 = new A.AdjustHandleList(); A.ConnectionSiteList connectionSiteList1 = new A.ConnectionSiteList(); A.Rectangle rectangle1 = new A.Rectangle() { Left = "0", Top = "0", Right = "0", Bottom = "0" }; A.PathList pathList1 = new A.PathList(); customGeometry1.Append(adjustValueList1); customGeometry1.Append(shapeGuideList1); customGeometry1.Append(adjustHandleList1); customGeometry1.Append(connectionSiteList1); customGeometry1.Append(rectangle1); customGeometry1.Append(pathList1); A.SolidFill solidFill6 = new A.SolidFill(); A.RgbColorModelHex rgbColorModelHex14 = new A.RgbColorModelHex() { Val = "FFFFFF" }; solidFill6.Append(rgbColorModelHex14); A.Outline outline4 = new A.Outline() { Width = 9525, CapType = A.LineCapValues.Flat, CompoundLineType = A.CompoundLineValues.Single, Alignment = A.PenAlignmentValues.Center }; A.SolidFill solidFill7 = new A.SolidFill(); A.RgbColorModelHex rgbColorModelHex15 = new A.RgbColorModelHex() { Val = "000000" }; solidFill7.Append(rgbColorModelHex15); A.PresetDash presetDash4 = new A.PresetDash() { Val = A.PresetLineDashValues.Solid }; A.Round round1 = new A.Round(); A.HeadEnd headEnd1 = new A.HeadEnd() { Type = A.LineEndValues.None, Width = A.LineEndWidthValues.Medium, Length = A.LineEndLengthValues.Medium }; A.TailEnd tailEnd1 = new A.TailEnd() { Type = A.LineEndValues.None, Width = A.LineEndWidthValues.Medium, Length = A.LineEndLengthValues.Medium }; outline4.Append(solidFill7); outline4.Append(presetDash4); outline4.Append(round1); outline4.Append(headEnd1); outline4.Append(tailEnd1); A.EffectList effectList4 = new A.EffectList(); shapeProperties1.Append(transform2D1); shapeProperties1.Append(customGeometry1); shapeProperties1.Append(solidFill6); shapeProperties1.Append(outline4); shapeProperties1.Append(effectList4); A.BodyProperties bodyProperties1 = new A.BodyProperties() { VerticalOverflow = A.TextVerticalOverflowValues.Clip, Wrap = A.TextWrappingValues.Square, LeftInset = 18288, TopInset = 0, RightInset = 0, BottomInset = 0, UpRight = true }; A.ListStyle listStyle1 = new A.ListStyle(); shapeDefault1.Append(shapeProperties1); shapeDefault1.Append(bodyProperties1); shapeDefault1.Append(listStyle1); A.LineDefault lineDefault1 = new A.LineDefault(); A.ShapeProperties shapeProperties2 = new A.ShapeProperties() { BlackWhiteMode = A.BlackWhiteModeValues.Auto }; A.Transform2D transform2D2 = new A.Transform2D(); A.Offset offset2 = new A.Offset() { X = 0L, Y = 0L }; A.Extents extents2 = new A.Extents() { Cx = 1L, Cy = 1L }; transform2D2.Append(offset2); transform2D2.Append(extents2); A.CustomGeometry customGeometry2 = new A.CustomGeometry(); A.AdjustValueList adjustValueList2 = new A.AdjustValueList(); A.ShapeGuideList shapeGuideList2 = new A.ShapeGuideList(); A.AdjustHandleList adjustHandleList2 = new A.AdjustHandleList(); A.ConnectionSiteList connectionSiteList2 = new A.ConnectionSiteList(); A.Rectangle rectangle2 = new A.Rectangle() { Left = "0", Top = "0", Right = "0", Bottom = "0" }; A.PathList pathList2 = new A.PathList(); customGeometry2.Append(adjustValueList2); customGeometry2.Append(shapeGuideList2); customGeometry2.Append(adjustHandleList2); customGeometry2.Append(connectionSiteList2); customGeometry2.Append(rectangle2); customGeometry2.Append(pathList2); A.SolidFill solidFill8 = new A.SolidFill(); A.RgbColorModelHex rgbColorModelHex16 = new A.RgbColorModelHex() { Val = "FFFFFF" }; solidFill8.Append(rgbColorModelHex16); A.Outline outline5 = new A.Outline() { Width = 9525, CapType = A.LineCapValues.Flat, CompoundLineType = A.CompoundLineValues.Single, Alignment = A.PenAlignmentValues.Center }; A.SolidFill solidFill9 = new A.SolidFill(); A.RgbColorModelHex rgbColorModelHex17 = new A.RgbColorModelHex() { Val = "000000" }; solidFill9.Append(rgbColorModelHex17); A.PresetDash presetDash5 = new A.PresetDash() { Val = A.PresetLineDashValues.Solid }; A.Round round2 = new A.Round(); A.HeadEnd headEnd2 = new A.HeadEnd() { Type = A.LineEndValues.None, Width = A.LineEndWidthValues.Medium, Length = A.LineEndLengthValues.Medium }; A.TailEnd tailEnd2 = new A.TailEnd() { Type = A.LineEndValues.None, Width = A.LineEndWidthValues.Medium, Length = A.LineEndLengthValues.Medium }; outline5.Append(solidFill9); outline5.Append(presetDash5); outline5.Append(round2); outline5.Append(headEnd2); outline5.Append(tailEnd2); A.EffectList effectList5 = new A.EffectList(); shapeProperties2.Append(transform2D2); shapeProperties2.Append(customGeometry2); shapeProperties2.Append(solidFill8); shapeProperties2.Append(outline5); shapeProperties2.Append(effectList5); A.BodyProperties bodyProperties2 = new A.BodyProperties() { VerticalOverflow = A.TextVerticalOverflowValues.Clip, Wrap = A.TextWrappingValues.Square, LeftInset = 18288, TopInset = 0, RightInset = 0, BottomInset = 0, UpRight = true }; A.ListStyle listStyle2 = new A.ListStyle(); lineDefault1.Append(shapeProperties2); lineDefault1.Append(bodyProperties2); lineDefault1.Append(listStyle2); objectDefaults1.Append(shapeDefault1); objectDefaults1.Append(lineDefault1); A.ExtraColorSchemeList extraColorSchemeList1 = new A.ExtraColorSchemeList(); theme1.Append(themeElements1); theme1.Append(objectDefaults1); theme1.Append(extraColorSchemeList1); themePart1.Theme = theme1; }
private void DrawWavyLine(Wpg.WordprocessingGroup wordprocessingGroup, Rect cmlExtents, Point bondStart, Point bondEnd) { UInt32Value id = UInt32Value.FromUInt32((uint)m_ooxmlId++); string bondLineName = "WavyLine" + id; Vector bondVector = bondEnd - bondStart; int noOfWiggles = (int)Math.Ceiling(bondVector.Length / BondOffset()); if (noOfWiggles < 1) { noOfWiggles = 1; } double wiggleLength = bondVector.Length / noOfWiggles; Vector originalWigglePortion = bondVector; originalWigglePortion.Normalize(); originalWigglePortion *= wiggleLength / 2; Matrix toLeft = new Matrix(); toLeft.Rotate(-60); Matrix toRight = new Matrix(); toRight.Rotate(60); Vector leftVector = originalWigglePortion * toLeft; Vector rightVector = originalWigglePortion * toRight; List <Point> allpoints = new List <Point>(); List <List <Point> > allTriangles = new List <List <Point> >(); List <Point> triangle = new List <Point>(); Point lastPoint = bondStart; allpoints.Add(lastPoint); triangle.Add(lastPoint); for (int i = 0; i < noOfWiggles; i++) { Point leftPoint = lastPoint + leftVector; allpoints.Add(leftPoint); triangle.Add(leftPoint); Point midPoint = lastPoint + originalWigglePortion; allpoints.Add(midPoint); triangle.Add(midPoint); allTriangles.Add(triangle); triangle = new List <Point>(); triangle.Add(midPoint); Point rightPoint = lastPoint + originalWigglePortion + rightVector; allpoints.Add(rightPoint); triangle.Add(rightPoint); lastPoint += originalWigglePortion * 2; allpoints.Add(lastPoint); triangle.Add(lastPoint); allTriangles.Add(triangle); triangle = new List <Point>(); triangle.Add(lastPoint); } double minX = double.MaxValue; double maxX = double.MinValue; double minY = double.MaxValue; double maxY = double.MinValue; foreach (Point p in allpoints) { maxX = Math.Max(p.X + cmlExtents.Left, maxX); minX = Math.Min(p.X + cmlExtents.Left, minX); maxY = Math.Max(p.Y + cmlExtents.Top, maxY); minY = Math.Min(p.Y + cmlExtents.Top, minY); } Rect newExtents = new Rect(minX, minY, maxX - minX, maxY - minY); double xOffset = cmlExtents.Left - newExtents.Left; double yOffset = cmlExtents.Top - newExtents.Top; Int64Value width = OoXmlHelper.ScaleCmlToEmu(newExtents.Width); Int64Value height = OoXmlHelper.ScaleCmlToEmu(newExtents.Height); Int64Value top = OoXmlHelper.ScaleCmlToEmu(newExtents.Top); Int64Value left = OoXmlHelper.ScaleCmlToEmu(newExtents.Left); Wps.WordprocessingShape shape = new Wps.WordprocessingShape(); Wps.NonVisualDrawingProperties nonVisualDrawingProperties = new Wps.NonVisualDrawingProperties() { Id = id, Name = bondLineName }; Wps.NonVisualDrawingShapeProperties nonVisualDrawingShapeProperties = new Wps.NonVisualDrawingShapeProperties(); Wps.ShapeProperties shapeProperties = new Wps.ShapeProperties(); A.Transform2D transform2D = new A.Transform2D(); A.Offset offset = new A.Offset { X = left, Y = top }; A.Extents extents = new A.Extents { Cx = width, Cy = height }; transform2D.Append(offset); transform2D.Append(extents); A.CustomGeometry customGeometry = new A.CustomGeometry(); A.AdjustValueList adjustValueList = new A.AdjustValueList(); A.Rectangle rectangle = new A.Rectangle { Left = "l", Top = "t", Right = "r", Bottom = "b" }; A.PathList pathList = new A.PathList(); A.Path path = new A.Path { Width = width, Height = height }; A.MoveTo moveTo = new A.MoveTo(); A.Point point1 = new A.Point { X = OoXmlHelper.ScaleCmlToEmu(bondStart.X + xOffset).ToString(), Y = OoXmlHelper.ScaleCmlToEmu(bondStart.Y + yOffset).ToString() }; moveTo.Append(point1); path.Append(moveTo); // Render as Curves foreach (var tri in allTriangles) { A.CubicBezierCurveTo cubicBezierCurveTo = new A.CubicBezierCurveTo(); foreach (var p in tri) { A.Point point = new A.Point { X = OoXmlHelper.ScaleCmlToEmu(p.X + xOffset).ToString(), Y = OoXmlHelper.ScaleCmlToEmu(p.Y + yOffset).ToString() }; cubicBezierCurveTo.Append(point); } path.Append(cubicBezierCurveTo); } // Render as Straight Lines //foreach (var p in allpoints) //{ // A.LineTo lineTo = new A.LineTo(); // A.Point point = new A.Point { X = OoXmlHelper.ScaleCmlToEmu(p.X + xOffset).ToString(), Y = OoXmlHelper.ScaleCmlToEmu(p.Y + yOffset).ToString() }; // lineTo.Append(point); // path1.Append(lineTo); //} pathList.Append(path); customGeometry.Append(adjustValueList); customGeometry.Append(rectangle); customGeometry.Append(pathList); A.Outline outline = new A.Outline { Width = OoXmlHelper.ACS_LINE_WIDTH_EMUS, CapType = A.LineCapValues.Round }; A.SolidFill solidFill = new A.SolidFill(); A.RgbColorModelHex rgbColorModelHex = new A.RgbColorModelHex { Val = "000000" }; solidFill.Append(rgbColorModelHex); outline.Append(solidFill); shapeProperties.Append(transform2D); shapeProperties.Append(customGeometry); shapeProperties.Append(outline); OoXmlHelper.AppendShapeStyle(shape, nonVisualDrawingProperties, nonVisualDrawingShapeProperties, shapeProperties); wordprocessingGroup.Append(shape); }
private void DrawWedgeBond(Wpg.WordprocessingGroup wordprocessingGroup, List <Point> points) { UInt32Value id = UInt32Value.FromUInt32((uint)m_ooxmlId++); string atomLabelName = "WedgeBond" + id; Rect cmlExtents = new Rect(points[0], points[points.Count - 1]); for (int i = 0; i < points.Count - 1; i++) { cmlExtents.Union(new Rect(points[i], points[i + 1])); } // Move Extents to have 0,0 Top Left Reference cmlExtents.Offset(-m_canvasExtents.Left, -m_canvasExtents.Top); Int64Value top = OoXmlHelper.ScaleCmlToEmu(cmlExtents.Y); Int64Value left = OoXmlHelper.ScaleCmlToEmu(cmlExtents.X); Int64Value width = OoXmlHelper.ScaleCmlToEmu(cmlExtents.Width); Int64Value height = OoXmlHelper.ScaleCmlToEmu(cmlExtents.Height); Wps.WordprocessingShape shape = new Wps.WordprocessingShape(); Wps.NonVisualDrawingProperties nonVisualDrawingProperties = new Wps.NonVisualDrawingProperties() { Id = id, Name = atomLabelName }; Wps.NonVisualDrawingShapeProperties nonVisualDrawingShapeProperties = new Wps.NonVisualDrawingShapeProperties(); Wps.ShapeProperties shapeProperties = new Wps.ShapeProperties(); A.Transform2D transform2D = new A.Transform2D(); A.Offset offset = new A.Offset { X = left, Y = top }; A.Extents extents = new A.Extents { Cx = width, Cy = height }; transform2D.Append(offset); transform2D.Append(extents); A.CustomGeometry customGeometry = new A.CustomGeometry(); A.AdjustValueList adjustValueList = new A.AdjustValueList(); A.Rectangle rectangle = new A.Rectangle { Left = "l", Top = "t", Right = "r", Bottom = "b" }; A.PathList pathList = new A.PathList(); A.Path path = new A.Path { Width = width, Height = height }; A.MoveTo moveTo = new A.MoveTo(); moveTo.Append(MakePoint(points[0])); path.Append(moveTo); for (int i = 1; i < points.Count; i++) { A.LineTo lineTo = new A.LineTo(); lineTo.Append(MakePoint(points[i])); path.Append(lineTo); } A.CloseShapePath closeShapePath = new A.CloseShapePath(); path.Append(closeShapePath); pathList.Append(path); customGeometry.Append(adjustValueList); customGeometry.Append(rectangle); customGeometry.Append(pathList); // Set shape fill colour A.SolidFill solidFill1 = new A.SolidFill(); A.RgbColorModelHex rgbColorModelHex = new A.RgbColorModelHex { Val = "000000" }; solidFill1.Append(rgbColorModelHex); // Set shape outline colour A.Outline outline = new A.Outline { Width = OoXmlHelper.ACS_LINE_WIDTH_EMUS, CapType = A.LineCapValues.Round }; A.RgbColorModelHex rgbColorModelHex2 = new A.RgbColorModelHex { Val = "000000" }; A.SolidFill solidFill2 = new A.SolidFill(); solidFill2.Append(rgbColorModelHex2); outline.Append(solidFill2); shapeProperties.Append(transform2D); shapeProperties.Append(customGeometry); shapeProperties.Append(solidFill1); shapeProperties.Append(outline); OoXmlHelper.AppendShapeStyle(shape, nonVisualDrawingProperties, nonVisualDrawingShapeProperties, shapeProperties); wordprocessingGroup.Append(shape); // Local Function A.Point MakePoint(Point pp) { pp.Offset(-m_canvasExtents.Left, -m_canvasExtents.Top); pp.Offset(-cmlExtents.Left, -cmlExtents.Top); return(new A.Point { X = $"{OoXmlHelper.ScaleCmlToEmu(pp.X)}", Y = $"{OoXmlHelper.ScaleCmlToEmu(pp.Y)}" }); } }
private void DrawDashedLine(Wpg.WordprocessingGroup wordprocessingGroup1, Rect extents, Point bondStart, Point bondEnd) { UInt32Value bondLineId = UInt32Value.FromUInt32((uint)m_ooxmlId++); string bondLineName = "DashedBondLine" + bondLineId; 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(bondStart.X).ToString(), Y = OoXmlHelper.ScaleCmlToEmu(bondStart.Y).ToString() }; moveTo1.Append(point1); A.LineTo lineTo1 = new A.LineTo(); A.Point point2 = new A.Point() { X = OoXmlHelper.ScaleCmlToEmu(bondEnd.X).ToString(), Y = OoXmlHelper.ScaleCmlToEmu(bondEnd.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 = 9525, CapType = A.LineCapValues.Round }; A.SolidFill solidFill1 = new A.SolidFill(); A.PresetDash presetDash1 = new A.PresetDash() { Val = A.PresetLineDashValues.LargeDash }; A.RgbColorModelHex rgbColorModelHex1 = new A.RgbColorModelHex() { Val = "000000" }; A.Alpha alpha1 = new A.Alpha() { Val = new Int32Value() { InnerText = "100%" } }; rgbColorModelHex1.Append(alpha1); solidFill1.Append(rgbColorModelHex1); outline1.Append(solidFill1); outline1.Append(presetDash1); 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 DrawWavyLine(Wpg.WordprocessingGroup wordprocessingGroup1, Rect extents, Point bondStart, Point bondEnd) { UInt32Value bondLineId = UInt32Value.FromUInt32((uint)m_ooxmlId++); string bondLineName = "WavyLine" + bondLineId; Vector bondVector = bondEnd - bondStart; int noOfWiggles = (int)Math.Ceiling(bondVector.Length / BondOffset()); if (noOfWiggles < 1) { noOfWiggles = 1; } double wiggleLength = bondVector.Length / noOfWiggles; Debug.WriteLine($"v.Length: {bondVector.Length} noOfWiggles: {noOfWiggles}"); Vector originalWigglePortion = bondVector; originalWigglePortion.Normalize(); originalWigglePortion *= wiggleLength / 2; Matrix toLeft = new Matrix(); toLeft.Rotate(-60); Matrix toRight = new Matrix(); toRight.Rotate(60); Vector leftVector = originalWigglePortion * toLeft; Vector rightVector = originalWigglePortion * toRight; List <Point> allpoints = new List <Point>(); List <List <Point> > allTriangles = new List <List <Point> >(); List <Point> triangle = new List <Point>(); Point lastPoint = bondStart; allpoints.Add(lastPoint); triangle.Add(lastPoint); for (int i = 0; i < noOfWiggles; i++) { Point leftPoint = lastPoint + leftVector; allpoints.Add(leftPoint); triangle.Add(leftPoint); Point midPoint = lastPoint + originalWigglePortion; allpoints.Add(midPoint); triangle.Add(midPoint); allTriangles.Add(triangle); triangle = new List <Point>(); triangle.Add(midPoint); Point rightPoint = lastPoint + originalWigglePortion + rightVector; allpoints.Add(rightPoint); triangle.Add(rightPoint); lastPoint += originalWigglePortion * 2; allpoints.Add(lastPoint); triangle.Add(lastPoint); allTriangles.Add(triangle); triangle = new List <Point>(); triangle.Add(lastPoint); } double minX = double.MaxValue; double maxX = double.MinValue; double minY = double.MaxValue; double maxY = double.MinValue; foreach (Point p in allpoints) { maxX = Math.Max(p.X + extents.Left, maxX); minX = Math.Min(p.X + extents.Left, minX); maxY = Math.Max(p.Y + extents.Top, maxY); minY = Math.Min(p.Y + extents.Top, minY); } Rect newExtents = new Rect(minX, minY, maxX - minX, maxY - minY); double xOffset = extents.Left - newExtents.Left; double yOffset = extents.Top - newExtents.Top; Int64Value width = OoXmlHelper.ScaleCmlToEmu(newExtents.Width); Int64Value height = OoXmlHelper.ScaleCmlToEmu(newExtents.Height); Int64Value top = OoXmlHelper.ScaleCmlToEmu(newExtents.Top); Int64Value left = OoXmlHelper.ScaleCmlToEmu(newExtents.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(bondStart.X + xOffset).ToString(), Y = OoXmlHelper.ScaleCmlToEmu(bondStart.Y + yOffset).ToString() }; moveTo1.Append(point1); path1.Append(moveTo1); //Curves foreach (var tri in allTriangles) { A.CubicBezierCurveTo cubicBezierCurveTo = new A.CubicBezierCurveTo(); foreach (var p in tri) { A.Point point = new A.Point() { X = OoXmlHelper.ScaleCmlToEmu(p.X + xOffset).ToString(), Y = OoXmlHelper.ScaleCmlToEmu(p.Y + yOffset).ToString() }; cubicBezierCurveTo.Append(point); } path1.Append(cubicBezierCurveTo); } //// Straight Lines //foreach (var p in allpoints) //{ // A.LineTo lineTo = new A.LineTo(); // A.Point point = new A.Point() { X = OoXmlHelper.ScaleCmlToEmu(p.X + xOffset).ToString(), Y = OoXmlHelper.ScaleCmlToEmu(p.Y + yOffset).ToString() }; // lineTo.Append(point); // path1.Append(lineTo); //} pathList1.Append(path1); customGeometry1.Append(adjustValueList1); customGeometry1.Append(rectangle1); customGeometry1.Append(pathList1); A.Outline outline1 = new A.Outline() { Width = 9525, CapType = A.LineCapValues.Round }; A.SolidFill solidFill1 = new A.SolidFill(); A.RgbColorModelHex rgbColorModelHex1 = new A.RgbColorModelHex() { Val = "000000" }; 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 DrawFilledTriangle(Wpg.WordprocessingGroup wordprocessingGroup1, List <Point> points) { UInt32Value atomLabelId = UInt32Value.FromUInt32((uint)m_ooxmlId++); string atomLabelName = "WedgeBond" + atomLabelId; double minX = double.MaxValue; double maxX = double.MinValue; double minY = double.MaxValue; double maxY = double.MinValue; foreach (Point p in points) { maxX = Math.Max(p.X, maxX); minX = Math.Min(p.X, minX); maxY = Math.Max(p.Y, maxY); minY = Math.Min(p.Y, minY); } Rect extents = new Rect(minX, minY, maxX - minX, maxY - minY); // Create modifyable Points Point p0 = new Point(points[0].X, points[0].Y); Point p1 = new Point(points[1].X, points[1].Y); Point p2 = new Point(points[2].X, points[2].Y); // Move Points to have 0,0 Top Left Reference within the drawing canvas p0.Offset(-m_canvasExtents.Left, -m_canvasExtents.Top); p1.Offset(-m_canvasExtents.Left, -m_canvasExtents.Top); p2.Offset(-m_canvasExtents.Left, -m_canvasExtents.Top); // Move shape's extents to correct place in drawing canvas extents.Offset(-m_canvasExtents.Left, -m_canvasExtents.Top); // Move points again to put them inside the shape's extents p0.Offset(-extents.Left, -extents.Top); p1.Offset(-extents.Left, -extents.Top); p2.Offset(-extents.Left, -extents.Top); Int64Value top = OoXmlHelper.ScaleCmlToEmu(extents.Y); Int64Value left = OoXmlHelper.ScaleCmlToEmu(extents.X); Int64Value width = OoXmlHelper.ScaleCmlToEmu(extents.Width); Int64Value height = OoXmlHelper.ScaleCmlToEmu(extents.Height); 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 }; string xCoOrdinate = OoXmlHelper.ScaleCmlToEmu(p0.X).ToString(); string yCoOrdinate = OoXmlHelper.ScaleCmlToEmu(p0.Y).ToString(); A.MoveTo moveTo10 = new A.MoveTo(); A.Point point19 = new A.Point() { X = xCoOrdinate, Y = yCoOrdinate }; moveTo10.Append(point19); path10.Append(moveTo10); xCoOrdinate = OoXmlHelper.ScaleCmlToEmu(p1.X).ToString(); yCoOrdinate = OoXmlHelper.ScaleCmlToEmu(p1.Y).ToString(); A.LineTo lineTo10 = new A.LineTo(); A.Point point20 = new A.Point() { X = xCoOrdinate, Y = yCoOrdinate }; lineTo10.Append(point20); path10.Append(lineTo10); xCoOrdinate = OoXmlHelper.ScaleCmlToEmu(p2.X).ToString(); yCoOrdinate = OoXmlHelper.ScaleCmlToEmu(p2.Y).ToString(); A.LineTo lineTo19 = new A.LineTo(); A.Point point29 = new A.Point() { X = xCoOrdinate, Y = yCoOrdinate }; lineTo19.Append(point29); path10.Append(lineTo19); 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(); A.RgbColorModelHex rgbColorModelHex10 = new A.RgbColorModelHex() { Val = "000000" }; 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); }
private void DrawBox(Wpg.WordprocessingGroup wordprocessingGroup1, Rect extents, string colour, int thick) { UInt32Value bondLineId = UInt32Value.FromUInt32((uint)_ooxmlId++); string bondLineName = "diag-box-" + 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; 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 = boundingBox.Width.ToString("0"), Y = "0" }; lineTo1.Append(point2); // Mid Point A.LineTo lineTo2 = new A.LineTo(); A.Point point3 = new A.Point() { X = boundingBox.Width.ToString("0"), Y = boundingBox.Height.ToString("0") }; lineTo2.Append(point3); // Last Point A.LineTo lineTo3 = new A.LineTo(); A.Point point4 = new A.Point() { X = "0", Y = boundingBox.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); }
public void DrawCharacter(Wpg.WordprocessingGroup wordprocessingGroup, AtomLabelCharacter alc) { Point characterPosition = new Point(alc.Position.X, alc.Position.Y); characterPosition.Offset(-_canvasExtents.Left, -_canvasExtents.Top); UInt32Value id = UInt32Value.FromUInt32((uint)_ooxmlId++); string atomLabelName = "Atom " + alc.ParentAtom; Int64Value width = OoXmlHelper.ScaleCsTtfToEmu(alc.Character.Width, _meanBondLength); Int64Value height = OoXmlHelper.ScaleCsTtfToEmu(alc.Character.Height, _meanBondLength); if (alc.IsSmaller) { width = OoXmlHelper.ScaleCsTtfSubScriptToEmu(alc.Character.Width, _meanBondLength); height = OoXmlHelper.ScaleCsTtfSubScriptToEmu(alc.Character.Height, _meanBondLength); } Int64Value top = OoXmlHelper.ScaleCmlToEmu(characterPosition.Y); Int64Value left = OoXmlHelper.ScaleCmlToEmu(characterPosition.X); // Set variable true to show bounding box of (every) character if (_options.ShowCharacterBoundingBoxes) { Rect boundingBox = new Rect(new Point(left, top), new Size(width, height)); DrawCharacterBox(wordprocessingGroup, boundingBox, "00ff00", 0.25); } Wps.WordprocessingShape shape = new Wps.WordprocessingShape(); Wps.NonVisualDrawingProperties nonVisualDrawingProperties = new Wps.NonVisualDrawingProperties() { Id = id, Name = atomLabelName }; Wps.NonVisualDrawingShapeProperties nonVisualDrawingShapeProperties = new Wps.NonVisualDrawingShapeProperties(); Wps.ShapeProperties shapeProperties = new Wps.ShapeProperties(); A.Transform2D transform2D = new A.Transform2D(); A.Offset offset = new A.Offset { X = left, Y = top }; A.Extents extents = new A.Extents { Cx = width, Cy = height }; transform2D.Append(offset); transform2D.Append(extents); A.CustomGeometry geometry = new A.CustomGeometry(); A.AdjustValueList adjustValueList = new A.AdjustValueList(); A.Rectangle rectangle = new A.Rectangle { Left = "l", Top = "t", Right = "r", Bottom = "b" }; A.PathList pathList = new A.PathList(); A.Path path = 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 moveTo = new A.MoveTo(); if (alc.IsSmaller) { A.Point point = MakeSubscriptPoint(thisPoint); moveTo.Append(point); path.Append(moveTo); } else { A.Point point = MakeNormalPoint(thisPoint); moveTo.Append(point); path.Append(moveTo); } i++; break; case TtfPoint.PointType.Line: A.LineTo lineTo = new A.LineTo(); if (alc.IsSmaller) { A.Point point = MakeSubscriptPoint(thisPoint); lineTo.Append(point); path.Append(lineTo); } else { A.Point point = MakeNormalPoint(thisPoint); lineTo.Append(point); path.Append(lineTo); } i++; break; case TtfPoint.PointType.CurveOff: A.QuadraticBezierCurveTo quadraticBezierCurveTo = new A.QuadraticBezierCurveTo(); if (alc.IsSmaller) { A.Point pointA = MakeSubscriptPoint(thisPoint); A.Point pointB = MakeSubscriptPoint(nextPoint); quadraticBezierCurveTo.Append(pointA); quadraticBezierCurveTo.Append(pointB); path.Append(quadraticBezierCurveTo); } else { A.Point pointA = MakeNormalPoint(thisPoint); A.Point pointB = MakeNormalPoint(nextPoint); quadraticBezierCurveTo.Append(pointA); quadraticBezierCurveTo.Append(pointB); path.Append(quadraticBezierCurveTo); } i++; i++; break; case TtfPoint.PointType.CurveOn: // Should never get here ! i++; break; } } A.CloseShapePath closeShapePath = new A.CloseShapePath(); path.Append(closeShapePath); } pathList.Append(path); geometry.Append(adjustValueList); geometry.Append(rectangle); geometry.Append(pathList); A.SolidFill solidFill = new A.SolidFill(); // Set Colour A.RgbColorModelHex rgbColorModelHex = new A.RgbColorModelHex { Val = alc.Colour }; solidFill.Append(rgbColorModelHex); shapeProperties.Append(transform2D); shapeProperties.Append(geometry); shapeProperties.Append(solidFill); OoXmlHelper.AppendShapeStyle(shape, nonVisualDrawingProperties, nonVisualDrawingShapeProperties, shapeProperties); wordprocessingGroup.Append(shape); // Local Functions A.Point MakeSubscriptPoint(TtfPoint ttfPoint) { A.Point pp = new A.Point { X = $"{OoXmlHelper.ScaleCsTtfSubScriptToEmu(ttfPoint.X - alc.Character.OriginX, _meanBondLength)}", Y = $"{OoXmlHelper.ScaleCsTtfSubScriptToEmu(alc.Character.Height + ttfPoint.Y - (alc.Character.Height + alc.Character.OriginY), _meanBondLength)}" }; return(pp); } A.Point MakeNormalPoint(TtfPoint ttfPoint) { A.Point pp = new A.Point { X = $"{OoXmlHelper.ScaleCsTtfToEmu(ttfPoint.X - alc.Character.OriginX, _meanBondLength)}", Y = $"{OoXmlHelper.ScaleCsTtfToEmu(alc.Character.Height + ttfPoint.Y - (alc.Character.Height + alc.Character.OriginY), _meanBondLength)}" }; return(pp); } }
private void DrawCharacterBox(Wpg.WordprocessingGroup wordprocessingGroup, Rect boxExtents, string colour, double points) { UInt32Value id = UInt32Value.FromUInt32((uint)_ooxmlId++); string bondLineName = "char-diag-box-" + id; Int64Value width = (Int64Value)boxExtents.Width; Int64Value height = (Int64Value)boxExtents.Height; Int64Value top = (Int64Value)boxExtents.Top; Int64Value left = (Int64Value)boxExtents.Left; Wps.WordprocessingShape shape = new Wps.WordprocessingShape(); Wps.NonVisualDrawingProperties nonVisualDrawingProperties = new Wps.NonVisualDrawingProperties() { Id = id, Name = bondLineName }; Wps.NonVisualDrawingShapeProperties nonVisualDrawingShapeProperties = new Wps.NonVisualDrawingShapeProperties(); Wps.ShapeProperties shapeProperties = new Wps.ShapeProperties(); A.Transform2D transform2D = new A.Transform2D(); A.Offset offset = new A.Offset { X = left, Y = top }; A.Extents extents = new A.Extents { Cx = width, Cy = height }; transform2D.Append(offset); transform2D.Append(extents); A.CustomGeometry customGeometry = new A.CustomGeometry(); A.AdjustValueList adjustValueList = new A.AdjustValueList(); A.Rectangle rectangle = new A.Rectangle { Left = "l", Top = "t", Right = "r", Bottom = "b" }; A.PathList pathList = new A.PathList(); A.Path path = new A.Path { Width = width, Height = height }; // Starting Point A.MoveTo moveTo = new A.MoveTo(); A.Point point1 = new A.Point { X = "0", Y = "0" }; moveTo.Append(point1); // Mid Point A.LineTo lineTo1 = new A.LineTo(); A.Point point2 = new A.Point { X = boxExtents.Width.ToString("0"), Y = "0" }; lineTo1.Append(point2); // Mid Point A.LineTo lineTo2 = new A.LineTo(); A.Point point3 = new A.Point { X = boxExtents.Width.ToString("0"), Y = boxExtents.Height.ToString("0") }; lineTo2.Append(point3); // Last Point A.LineTo lineTo3 = new A.LineTo(); A.Point point4 = new A.Point { X = "0", Y = boxExtents.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); path.Append(moveTo); path.Append(lineTo1); path.Append(lineTo2); path.Append(lineTo3); path.Append(lineTo4); pathList.Append(path); customGeometry.Append(adjustValueList); customGeometry.Append(rectangle); customGeometry.Append(pathList); Int32Value emus = (Int32Value)(points * OoXmlHelper.EMUS_PER_WORD_POINT); A.Outline outline = new A.Outline { Width = emus, CapType = A.LineCapValues.Round }; A.SolidFill solidFill = new A.SolidFill(); A.RgbColorModelHex rgbColorModelHex = new A.RgbColorModelHex { Val = colour }; solidFill.Append(rgbColorModelHex); outline.Append(solidFill); shapeProperties.Append(transform2D); shapeProperties.Append(customGeometry); shapeProperties.Append(outline); OoXmlHelper.AppendShapeStyle(shape, nonVisualDrawingProperties, nonVisualDrawingShapeProperties, shapeProperties); wordprocessingGroup.Append(shape); }
public void DrawCharacter(Wpg.WordprocessingGroup wordprocessingGroup1, AtomLabelCharacter alc) { Point characterPosition = new Point(alc.Position.X, alc.Position.Y); characterPosition.Offset(-_canvasExtents.Left, -_canvasExtents.Top); UInt32Value atomLabelId = UInt32Value.FromUInt32((uint)_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 (_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 }; 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); }