|
| 1 | +using System.Text; |
| 2 | + |
| 3 | +using DocumentFormat.OpenXml.Drawing; |
| 4 | +using DocumentFormat.OpenXml.Flatten.Contexts; |
| 5 | + |
| 6 | +using dotnetCampus.OpenXmlUnitConverter; |
| 7 | + |
| 8 | +using static DocumentFormat.OpenXml.Flatten.ElementConverters.ShapeGeometryConverters.ShapeGeometryFormulaHelper; |
| 9 | + |
| 10 | +using ElementEmuSize = dotnetCampus.OpenXmlUnitConverter.EmuSize; |
| 11 | + |
| 12 | +namespace DocumentFormat.OpenXml.Flatten.ElementConverters.ShapeGeometryConverters |
| 13 | +{ |
| 14 | + /// <summary> |
| 15 | + /// 动作按钮: 后退或前一项 |
| 16 | + /// </summary> |
| 17 | + public class ActionButtonBackPreviousGeometry : ShapeGeometryBase |
| 18 | + { |
| 19 | + /// <inheritdoc /> |
| 20 | + public override string? ToGeometryPathString(EmuSize emuSize, AdjustValueList? adjusts = null) |
| 21 | + { |
| 22 | + return null; |
| 23 | + } |
| 24 | + |
| 25 | + /// <inheritdoc /> |
| 26 | + public override ShapePath[]? GetMultiShapePaths(EmuSize emuSize, AdjustValueList? adjusts = null) |
| 27 | + { |
| 28 | + var (h, w, l, r, t, b, hd2, hd4, hd5, hd6, hd8, ss, hc, vc, ls, ss2, ss4, ss6, ss8, wd2, wd4, wd5, wd6, wd8, wd10, cd2, cd4, cd6, cd8) = GetFormulaProperties(emuSize); |
| 29 | + |
| 30 | + //<gdLst xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"> |
| 31 | + // <gd name="dx2" fmla="*/ ss 3 8" /> |
| 32 | + // <gd name="g9" fmla="+- vc 0 dx2" /> |
| 33 | + // <gd name="g10" fmla="+- vc dx2 0" /> |
| 34 | + // <gd name="g11" fmla="+- hc 0 dx2" /> |
| 35 | + // <gd name="g12" fmla="+- hc dx2 0" /> |
| 36 | + //</gdLst> |
| 37 | + |
| 38 | + //<gd name="dx2" fmla="*/ ss 3 8" xmlns="http://schemas.openxmlformats.org/drawingml/2006/main" /> |
| 39 | + var dx2 = ss * 3 / 8; |
| 40 | + //<gd name="g9" fmla="+- vc 0 dx2" xmlns="http://schemas.openxmlformats.org/drawingml/2006/main" /> |
| 41 | + var g9 = vc + 0 - dx2; |
| 42 | + //<gd name="g10" fmla="+- vc dx2 0" xmlns="http://schemas.openxmlformats.org/drawingml/2006/main" /> |
| 43 | + var g10 = vc + dx2 - 0; |
| 44 | + //<gd name="g11" fmla="+- hc 0 dx2" xmlns="http://schemas.openxmlformats.org/drawingml/2006/main" /> |
| 45 | + var g11 = hc + 0 - dx2; |
| 46 | + //<gd name="g12" fmla="+- hc dx2 0" xmlns="http://schemas.openxmlformats.org/drawingml/2006/main" /> |
| 47 | + var g12 = hc + dx2 - 0; |
| 48 | + |
| 49 | + //<pathLst xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"> |
| 50 | + // <path stroke="false" extrusionOk="false"> |
| 51 | + // <moveTo> |
| 52 | + // <pt x="l" y="t" /> |
| 53 | + // </moveTo> |
| 54 | + // <lnTo> |
| 55 | + // <pt x="r" y="t" /> |
| 56 | + // </lnTo> |
| 57 | + // <lnTo> |
| 58 | + // <pt x="r" y="b" /> |
| 59 | + // </lnTo> |
| 60 | + // <lnTo> |
| 61 | + // <pt x="l" y="b" /> |
| 62 | + // </lnTo> |
| 63 | + // <close /> |
| 64 | + // <moveTo> |
| 65 | + // <pt x="g11" y="vc" /> |
| 66 | + // </moveTo> |
| 67 | + // <lnTo> |
| 68 | + // <pt x="g12" y="g9" /> |
| 69 | + // </lnTo> |
| 70 | + // <lnTo> |
| 71 | + // <pt x="g12" y="g10" /> |
| 72 | + // </lnTo> |
| 73 | + // <close /> |
| 74 | + // </path> |
| 75 | + // <path stroke="false" fill="darken" extrusionOk="false"> |
| 76 | + // <moveTo> |
| 77 | + // <pt x="g11" y="vc" /> |
| 78 | + // </moveTo> |
| 79 | + // <lnTo> |
| 80 | + // <pt x="g12" y="g9" /> |
| 81 | + // </lnTo> |
| 82 | + // <lnTo> |
| 83 | + // <pt x="g12" y="g10" /> |
| 84 | + // </lnTo> |
| 85 | + // <close /> |
| 86 | + // </path> |
| 87 | + // <path fill="none" extrusionOk="false"> |
| 88 | + // <moveTo> |
| 89 | + // <pt x="g11" y="vc" /> |
| 90 | + // </moveTo> |
| 91 | + // <lnTo> |
| 92 | + // <pt x="g12" y="g9" /> |
| 93 | + // </lnTo> |
| 94 | + // <lnTo> |
| 95 | + // <pt x="g12" y="g10" /> |
| 96 | + // </lnTo> |
| 97 | + // <close /> |
| 98 | + // </path> |
| 99 | + // <path fill="none"> |
| 100 | + // <moveTo> |
| 101 | + // <pt x="l" y="t" /> |
| 102 | + // </moveTo> |
| 103 | + // <lnTo> |
| 104 | + // <pt x="r" y="t" /> |
| 105 | + // </lnTo> |
| 106 | + // <lnTo> |
| 107 | + // <pt x="r" y="b" /> |
| 108 | + // </lnTo> |
| 109 | + // <lnTo> |
| 110 | + // <pt x="l" y="b" /> |
| 111 | + // </lnTo> |
| 112 | + // <close /> |
| 113 | + // </path> |
| 114 | + //</pathLst> |
| 115 | + |
| 116 | + var shapePaths = new ShapePath[4]; |
| 117 | + |
| 118 | + // <path stroke="false"extrusionOk="false"> |
| 119 | + //<moveTo xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"> |
| 120 | + // <pt x="l" y="t" /> |
| 121 | + //</moveTo> |
| 122 | + var currentPoint = new EmuPoint(l, t); |
| 123 | + var stringPath = new StringBuilder(); |
| 124 | + stringPath.Append($"M {EmuToPixelString(currentPoint.X)},{EmuToPixelString(currentPoint.Y)} "); |
| 125 | + //<lnTo xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"> |
| 126 | + // <pt x="r" y="t" /> |
| 127 | + //</lnTo> |
| 128 | + currentPoint = LineToToString(stringPath, r, t); |
| 129 | + //<lnTo xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"> |
| 130 | + // <pt x="r" y="b" /> |
| 131 | + //</lnTo> |
| 132 | + currentPoint = LineToToString(stringPath, r, b); |
| 133 | + //<lnTo xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"> |
| 134 | + // <pt x="l" y="b" /> |
| 135 | + //</lnTo> |
| 136 | + currentPoint = LineToToString(stringPath, l, b); |
| 137 | + //<close xmlns="http://schemas.openxmlformats.org/drawingml/2006/main" /> |
| 138 | + stringPath.Append("z "); |
| 139 | + //<moveTo xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"> |
| 140 | + // <pt x="g11" y="vc" /> |
| 141 | + //</moveTo> |
| 142 | + currentPoint = new EmuPoint(g11, vc); |
| 143 | + stringPath.Append($"M {EmuToPixelString(currentPoint.X)},{EmuToPixelString(currentPoint.Y)} "); |
| 144 | + //<lnTo xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"> |
| 145 | + // <pt x="g12" y="g9" /> |
| 146 | + //</lnTo> |
| 147 | + currentPoint = LineToToString(stringPath, g12, g9); |
| 148 | + //<lnTo xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"> |
| 149 | + // <pt x="g12" y="g10" /> |
| 150 | + //</lnTo> |
| 151 | + currentPoint = LineToToString(stringPath, g12, g10); |
| 152 | + //<close xmlns="http://schemas.openxmlformats.org/drawingml/2006/main" /> |
| 153 | + stringPath.Append("z "); |
| 154 | + shapePaths[0] = new ShapePath(stringPath.ToString(), isStroke: false); |
| 155 | + |
| 156 | + |
| 157 | + // <path stroke="false"fill="darken"extrusionOk="false"> |
| 158 | + //<moveTo xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"> |
| 159 | + // <pt x="g11" y="vc" /> |
| 160 | + //</moveTo> |
| 161 | + currentPoint = new EmuPoint(g11, vc); |
| 162 | + stringPath.Clear(); |
| 163 | + stringPath.Append($"M {EmuToPixelString(currentPoint.X)},{EmuToPixelString(currentPoint.Y)} "); |
| 164 | + //<lnTo xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"> |
| 165 | + // <pt x="g12" y="g9" /> |
| 166 | + //</lnTo> |
| 167 | + currentPoint = LineToToString(stringPath, g12, g9); |
| 168 | + //<lnTo xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"> |
| 169 | + // <pt x="g12" y="g10" /> |
| 170 | + //</lnTo> |
| 171 | + currentPoint = LineToToString(stringPath, g12, g10); |
| 172 | + //<close xmlns="http://schemas.openxmlformats.org/drawingml/2006/main" /> |
| 173 | + stringPath.Append("z "); |
| 174 | + shapePaths[1] = new ShapePath(stringPath.ToString(), PathFillModeValues.Darken, isStroke: false); |
| 175 | + |
| 176 | + |
| 177 | + // <path fill="none"extrusionOk="false"> |
| 178 | + //<moveTo xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"> |
| 179 | + // <pt x="g11" y="vc" /> |
| 180 | + //</moveTo> |
| 181 | + currentPoint = new EmuPoint(g11, vc); |
| 182 | + stringPath.Clear(); |
| 183 | + stringPath.Append($"M {EmuToPixelString(currentPoint.X)},{EmuToPixelString(currentPoint.Y)} "); |
| 184 | + //<lnTo xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"> |
| 185 | + // <pt x="g12" y="g9" /> |
| 186 | + //</lnTo> |
| 187 | + currentPoint = LineToToString(stringPath, g12, g9); |
| 188 | + //<lnTo xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"> |
| 189 | + // <pt x="g12" y="g10" /> |
| 190 | + //</lnTo> |
| 191 | + currentPoint = LineToToString(stringPath, g12, g10); |
| 192 | + //<close xmlns="http://schemas.openxmlformats.org/drawingml/2006/main" /> |
| 193 | + stringPath.Append("z "); |
| 194 | + shapePaths[2] = new ShapePath(stringPath.ToString(), PathFillModeValues.None); |
| 195 | + |
| 196 | + |
| 197 | + // <path fill="none"> |
| 198 | + //<moveTo xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"> |
| 199 | + // <pt x="l" y="t" /> |
| 200 | + //</moveTo> |
| 201 | + currentPoint = new EmuPoint(l, t); |
| 202 | + stringPath.Clear(); |
| 203 | + stringPath.Append($"M {EmuToPixelString(currentPoint.X)},{EmuToPixelString(currentPoint.Y)} "); |
| 204 | + //<lnTo xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"> |
| 205 | + // <pt x="r" y="t" /> |
| 206 | + //</lnTo> |
| 207 | + currentPoint = LineToToString(stringPath, r, t); |
| 208 | + //<lnTo xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"> |
| 209 | + // <pt x="r" y="b" /> |
| 210 | + //</lnTo> |
| 211 | + currentPoint = LineToToString(stringPath, r, b); |
| 212 | + //<lnTo xmlns="http://schemas.openxmlformats.org/drawingml/2006/main"> |
| 213 | + // <pt x="l" y="b" /> |
| 214 | + //</lnTo> |
| 215 | + currentPoint = LineToToString(stringPath, l, b); |
| 216 | + //<close xmlns="http://schemas.openxmlformats.org/drawingml/2006/main" /> |
| 217 | + stringPath.Append("z "); |
| 218 | + shapePaths[3] = new ShapePath(stringPath.ToString(), PathFillModeValues.None); |
| 219 | + |
| 220 | + |
| 221 | + //<rect l="l" t="t" r="r" b="b" xmlns="http://schemas.openxmlformats.org/drawingml/2006/main" /> |
| 222 | + InitializeShapeTextRectangle(l, t, r, b); |
| 223 | + |
| 224 | + return shapePaths; |
| 225 | + } |
| 226 | + } |
| 227 | + |
| 228 | + |
| 229 | +} |
| 230 | + |
0 commit comments