/** * Write this RtfShapePosition. */ public override void WriteContent(Stream result) { byte[] t; result.Write(RtfElement.OPEN_GROUP, 0, RtfElement.OPEN_GROUP.Length); result.Write(t = DocWriter.GetISOBytes("\\sp"), 0, t.Length); result.Write(RtfElement.OPEN_GROUP, 0, RtfElement.OPEN_GROUP.Length); result.Write(t = DocWriter.GetISOBytes("\\sn"), 0, t.Length); result.Write(RtfElement.DELIMITER, 0, RtfElement.DELIMITER.Length); result.Write(t = DocWriter.GetISOBytes(this.name), 0, t.Length); result.Write(RtfElement.CLOSE_GROUP, 0, RtfElement.CLOSE_GROUP.Length); result.Write(RtfElement.OPEN_GROUP, 0, RtfElement.OPEN_GROUP.Length); result.Write(t = DocWriter.GetISOBytes("\\sv"), 0, t.Length); result.Write(RtfElement.DELIMITER, 0, RtfElement.DELIMITER.Length); switch (this.type) { case PROPERTY_TYPE_LONG: case PROPERTY_TYPE_DOUBLE: result.Write(t = DocWriter.GetISOBytes(this.value.ToString()), 0, t.Length); break; case PROPERTY_TYPE_BOOLEAN: if ((bool)this.value) { result.Write(t = DocWriter.GetISOBytes("1"), 0, t.Length); } else { result.Write(t = DocWriter.GetISOBytes("0"), 0, t.Length); } break; case PROPERTY_TYPE_COLOR: Color color = (Color) this.value; result.Write(t = IntToByteArray(color.R | (color.G << 8) | (color.B << 16)), 0, t.Length); break; case PROPERTY_TYPE_ARRAY: if (this.value is int[]) { int[] values = (int[]) this.value; result.Write(t = DocWriter.GetISOBytes("4;"), 0, t.Length); result.Write(t = IntToByteArray(values.Length), 0, t.Length); result.Write(RtfElement.COMMA_DELIMITER, 0, RtfElement.COMMA_DELIMITER.Length); for (int i = 0; i < values.Length; i++) { result.Write(t = IntToByteArray(values[i]), 0, t.Length); if (i < values.Length - 1) { result.Write(RtfElement.COMMA_DELIMITER, 0, RtfElement.COMMA_DELIMITER.Length); } } } else if (this.value is Point[]) { Point[] values = (Point[]) this.value; result.Write(t = DocWriter.GetISOBytes("8;"), 0, t.Length); result.Write(t = IntToByteArray(values.Length), 0, t.Length); result.Write(RtfElement.COMMA_DELIMITER, 0, RtfElement.COMMA_DELIMITER.Length); for (int i = 0; i < values.Length; i++) { result.Write(t = DocWriter.GetISOBytes("("), 0, t.Length); result.Write(t = IntToByteArray(values[i].X), 0, t.Length); result.Write(t = DocWriter.GetISOBytes(","), 0, t.Length); result.Write(t = IntToByteArray(values[i].Y), 0, t.Length); result.Write(t = DocWriter.GetISOBytes(")"), 0, t.Length); if (i < values.Length - 1) { result.Write(RtfElement.COMMA_DELIMITER, 0, RtfElement.COMMA_DELIMITER.Length); } } } break; case PROPERTY_TYPE_IMAGE: Image image = (Image)this.value; RtfImage img = new RtfImage(this.doc, image); img.SetTopLevelElement(true); result.Write(RtfElement.OPEN_GROUP, 0, RtfElement.OPEN_GROUP.Length); img.WriteContent(result); result.Write(RtfElement.CLOSE_GROUP, 0, RtfElement.CLOSE_GROUP.Length); break; } result.Write(RtfElement.CLOSE_GROUP, 0, RtfElement.CLOSE_GROUP.Length); result.Write(RtfElement.CLOSE_GROUP, 0, RtfElement.CLOSE_GROUP.Length); }
/** * Write this RtfShapePosition. */ public override void WriteContent(Stream result) { byte[] t; result.Write(RtfElement.OPEN_GROUP, 0, RtfElement.OPEN_GROUP.Length); result.Write(t = DocWriter.GetISOBytes("\\sp"), 0, t.Length); result.Write(RtfElement.OPEN_GROUP, 0, RtfElement.OPEN_GROUP.Length); result.Write(t = DocWriter.GetISOBytes("\\sn"), 0, t.Length); result.Write(RtfElement.DELIMITER, 0, RtfElement.DELIMITER.Length); result.Write(t = DocWriter.GetISOBytes(this.name), 0, t.Length); result.Write(RtfElement.CLOSE_GROUP, 0, RtfElement.CLOSE_GROUP.Length); result.Write(RtfElement.OPEN_GROUP, 0, RtfElement.OPEN_GROUP.Length); result.Write(t = DocWriter.GetISOBytes("\\sv"), 0, t.Length); result.Write(RtfElement.DELIMITER, 0, RtfElement.DELIMITER.Length); switch (this.type) { case PROPERTY_TYPE_LONG: case PROPERTY_TYPE_DOUBLE: result.Write(t = DocWriter.GetISOBytes(this.value.ToString()), 0, t.Length); break; case PROPERTY_TYPE_BOOLEAN: if ((bool)this.value) { result.Write(t = DocWriter.GetISOBytes("1"), 0, t.Length); } else { result.Write(t = DocWriter.GetISOBytes("0"), 0, t.Length); } break; case PROPERTY_TYPE_COLOR: Color color = (Color)this.value; result.Write(t = IntToByteArray(color.R | (color.G << 8) | (color.B << 16)), 0, t.Length); break; case PROPERTY_TYPE_ARRAY: if (this.value is int[]) { int[] values = (int[])this.value; result.Write(t = DocWriter.GetISOBytes("4;"), 0, t.Length); result.Write(t = IntToByteArray(values.Length), 0, t.Length); result.Write(RtfElement.COMMA_DELIMITER, 0, RtfElement.COMMA_DELIMITER.Length); for (int i = 0; i < values.Length; i++) { result.Write(t = IntToByteArray(values[i]), 0, t.Length); if (i < values.Length - 1) { result.Write(RtfElement.COMMA_DELIMITER, 0, RtfElement.COMMA_DELIMITER.Length); } } } else if (this.value is Point[]) { Point[] values = (Point[])this.value; result.Write(t = DocWriter.GetISOBytes("8;"), 0, t.Length); result.Write(t = IntToByteArray(values.Length), 0, t.Length); result.Write(RtfElement.COMMA_DELIMITER, 0, RtfElement.COMMA_DELIMITER.Length); for (int i = 0; i < values.Length; i++) { result.Write(t = DocWriter.GetISOBytes("("), 0, t.Length); result.Write(t = IntToByteArray(values[i].X), 0, t.Length); result.Write(t = DocWriter.GetISOBytes(","), 0, t.Length); result.Write(t = IntToByteArray(values[i].Y), 0, t.Length); result.Write(t = DocWriter.GetISOBytes(")"), 0, t.Length); if (i < values.Length - 1) { result.Write(RtfElement.COMMA_DELIMITER, 0, RtfElement.COMMA_DELIMITER.Length); } } } break; case PROPERTY_TYPE_IMAGE: Image image = (Image)this.value; RtfImage img = new RtfImage(this.doc, image); img.SetTopLevelElement(true); result.Write(RtfElement.OPEN_GROUP, 0, RtfElement.OPEN_GROUP.Length); img.WriteContent(result); result.Write(RtfElement.CLOSE_GROUP, 0, RtfElement.CLOSE_GROUP.Length); break; } result.Write(RtfElement.CLOSE_GROUP, 0, RtfElement.CLOSE_GROUP.Length); result.Write(RtfElement.CLOSE_GROUP, 0, RtfElement.CLOSE_GROUP.Length); }
/// <summary> /// Write this RtfShapePosition. /// </summary> public override void WriteContent(Stream result) { byte[] t; result.Write(RtfElement.OpenGroup, 0, RtfElement.OpenGroup.Length); result.Write(t = DocWriter.GetIsoBytes("\\sp"), 0, t.Length); result.Write(RtfElement.OpenGroup, 0, RtfElement.OpenGroup.Length); result.Write(t = DocWriter.GetIsoBytes("\\sn"), 0, t.Length); result.Write(RtfElement.Delimiter, 0, RtfElement.Delimiter.Length); result.Write(t = DocWriter.GetIsoBytes(_name), 0, t.Length); result.Write(RtfElement.CloseGroup, 0, RtfElement.CloseGroup.Length); result.Write(RtfElement.OpenGroup, 0, RtfElement.OpenGroup.Length); result.Write(t = DocWriter.GetIsoBytes("\\sv"), 0, t.Length); result.Write(RtfElement.Delimiter, 0, RtfElement.Delimiter.Length); switch (_type) { case PropertyTypeLong: case PropertyTypeDouble: result.Write(t = DocWriter.GetIsoBytes(_value.ToString()), 0, t.Length); break; case PropertyTypeBoolean: if ((bool)_value) { result.Write(t = DocWriter.GetIsoBytes("1"), 0, t.Length); } else { result.Write(t = DocWriter.GetIsoBytes("0"), 0, t.Length); } break; case PropertyTypeColor: var color = (BaseColor)_value; result.Write(t = IntToByteArray(color.R | (color.G << 8) | (color.B << 16)), 0, t.Length); break; case PropertyTypeArray: if (_value is int[]) { var values = (int[])_value; result.Write(t = DocWriter.GetIsoBytes("4;"), 0, t.Length); result.Write(t = IntToByteArray(values.Length), 0, t.Length); result.Write(RtfElement.CommaDelimiter, 0, RtfElement.CommaDelimiter.Length); for (var i = 0; i < values.Length; i++) { result.Write(t = IntToByteArray(values[i]), 0, t.Length); if (i < values.Length - 1) { result.Write(RtfElement.CommaDelimiter, 0, RtfElement.CommaDelimiter.Length); } } } else if (_value is Point[]) { var values = (Point[])_value; result.Write(t = DocWriter.GetIsoBytes("8;"), 0, t.Length); result.Write(t = IntToByteArray(values.Length), 0, t.Length); result.Write(RtfElement.CommaDelimiter, 0, RtfElement.CommaDelimiter.Length); for (var i = 0; i < values.Length; i++) { result.Write(t = DocWriter.GetIsoBytes("("), 0, t.Length); result.Write(t = IntToByteArray(values[i].X), 0, t.Length); result.Write(t = DocWriter.GetIsoBytes(","), 0, t.Length); result.Write(t = IntToByteArray(values[i].Y), 0, t.Length); result.Write(t = DocWriter.GetIsoBytes(")"), 0, t.Length); if (i < values.Length - 1) { result.Write(RtfElement.CommaDelimiter, 0, RtfElement.CommaDelimiter.Length); } } } break; case PropertyTypeImage: var image = (Image)_value; var img = new RtfImage(Doc, image); img.SetTopLevelElement(true); result.Write(RtfElement.OpenGroup, 0, RtfElement.OpenGroup.Length); img.WriteContent(result); result.Write(RtfElement.CloseGroup, 0, RtfElement.CloseGroup.Length); break; } result.Write(RtfElement.CloseGroup, 0, RtfElement.CloseGroup.Length); result.Write(RtfElement.CloseGroup, 0, RtfElement.CloseGroup.Length); }