private static void DeserializeArcTo(BinaryReader br, byte firstByte, StreamGeometryContext sc) { Point point; Size size = new Size(); double rotationAngle; bool isStroked; bool isSmoothJoin; bool isLargeArc; SweepDirection sweepDirection; DeserializePointAndTwoBools(br, firstByte, out point, out isStroked, out isSmoothJoin); // Read the packed byte for isLargeArd & sweepDirection. // // Pack isLargeArc & sweepDirection into a signle byte. // byte packedByte = br.ReadByte(); isLargeArc = ((packedByte & LowNibble) != 0); sweepDirection = BoolToSweep(((packedByte & HighNibble) != 0)); size.Width = XamlSerializationHelper.ReadDouble(br); size.Height = XamlSerializationHelper.ReadDouble(br); rotationAngle = XamlSerializationHelper.ReadDouble(br); sc.ArcTo(point, size, rotationAngle, isLargeArc, sweepDirection, isStroked, isSmoothJoin); }
public override void ArcTo(Point point, Size size, double rotationAngle, bool isLargeArc, SweepDirection sweepDirection, bool isStroked, bool isSmoothJoin) #endif { SerializePointAndTwoBools(ParserGeometryContextOpCodes.ArcTo, point, isStroked, isSmoothJoin); // // Pack isLargeArc & sweepDirection into a single byte. // byte packMe = 0; if (isLargeArc) { packMe = LowNibble; } #if PBTCOMPILER if (sweepDirection) #else if (SweepToBool(sweepDirection)) #endif { packMe |= HighNibble; } _bw.Write(packMe); // // Write out Size & Rotation Angle. // XamlSerializationHelper.WriteDouble(_bw, size.Width); XamlSerializationHelper.WriteDouble(_bw, size.Height); XamlSerializationHelper.WriteDouble(_bw, rotationAngle); }
/// <summary> /// QuadraticBezierTo - append a QuadraticBezierTo to the current figure. /// </summary> /// <remarks> /// Stored as [PointAndTwoBools] [Number] [Number] /// </remarks> public override void QuadraticBezierTo(Point point1, Point point2, bool isStroked, bool isSmoothJoin) { SerializePointAndTwoBools(ParserGeometryContextOpCodes.QuadraticBezierTo, point1, isStroked, isSmoothJoin); XamlSerializationHelper.WriteDouble(_bw, point2.X); XamlSerializationHelper.WriteDouble(_bw, point2.Y); }
private void SerializeDouble(double value, bool isScaledInt, int scaledIntValue) { if (isScaledInt) { _bw.Write(scaledIntValue); } else { XamlSerializationHelper.WriteDouble(_bw, value); } }
private static Double DeserializeDouble(BinaryReader br, bool isScaledInt) { if (isScaledInt) { return(XamlSerializationHelper.ReadScaledInteger(br)); } else { return(XamlSerializationHelper.ReadDouble(br)); } }
private static void DeserializeQuadraticBezierTo(BinaryReader br, byte firstByte, StreamGeometryContext sc) { Point point1; Point point2 = new Point(); bool isStroked; bool isSmoothJoin; DeserializePointAndTwoBools(br, firstByte, out point1, out isStroked, out isSmoothJoin); point2.X = XamlSerializationHelper.ReadDouble(br); point2.Y = XamlSerializationHelper.ReadDouble(br); sc.QuadraticBezierTo(point1, point2, isStroked, isSmoothJoin); }
// SerializeListOfPointsAndTwoBools // // Binary format is : // // <Byte+OpCode> <Count> <Number1> ... <NumberN> // // <Byte+OpCode> := OpCode + bool1 + bool2 // <Count> := int32 // <NumberN> := <SerializationFloatType.ScaledInteger+Integer> | <SerializationFloatTypeForSpecialNumbers> | <SerializationFloatType.Double+Double> private void SerializeListOfPointsAndTwoBools(ParserGeometryContextOpCodes opCode, IList <Point> points, bool bool1, bool bool2) { // Pack the two bools into one byte Byte packedByte = PackByte(opCode, bool1, bool2); _bw.Write(packedByte); // Write the count. _bw.Write(points.Count); // Write out all the Points for (int i = 0; i < points.Count; i++) { XamlSerializationHelper.WriteDouble(_bw, points[i].X); XamlSerializationHelper.WriteDouble(_bw, points[i].Y); } }
// // SerializePointAndTwoBools // // Binary format is : // // <Byte+OpCode> <Number1> <Number2> // // Where : // <Byte+OpCode> := OpCode + bool1 + bool2 + isScaledIntegerX + isScaledIntegerY // <NumberN> := <ScaledInteger> | <SerializationFloatTypeForSpecialNumbers> | <SerializationFloatType.Double+Double> // <SerializationFloatTypeForSpecialNumbers> := <SerializationFloatType.Zero> | <SerializationFloatType.One> | <SerializationFloatType.MinusOne> // <SerializationFloatType.Double+Double> := <SerializationFloatType.Double> <Double> // // By packing the flags for isScaledInteger into the first byte - we save 2 extra bytes per number for the common case. // // As a result - most LineTo's (and other operations) will be stored in 9 bytes. // Some LineTo's will be 6 (or even sometimes 3) // Max LineTo will be 19 (two doubles). private void SerializePointAndTwoBools(ParserGeometryContextOpCodes opCode, Point point, bool bool1, bool bool2) { int intValueX = 0; int intValueY = 0; bool isScaledIntegerX, isScaledIntegerY; isScaledIntegerX = XamlSerializationHelper.CanConvertToInteger(point.X, ref intValueX); isScaledIntegerY = XamlSerializationHelper.CanConvertToInteger(point.Y, ref intValueY); _bw.Write(PackByte(opCode, bool1, bool2, isScaledIntegerX, isScaledIntegerY)); SerializeDouble(point.X, isScaledIntegerX, intValueX); SerializeDouble(point.Y, isScaledIntegerY, intValueY); }
[FriendAccessAllowed] // Built into Core, also used by Framework. internal static object DeserializeFrom(BinaryReader reader) { // Get the size. uint count = reader.ReadUInt32(); PointCollection collection = new PointCollection((int)count); for (uint i = 0; i < count; i++) { Point point = new Point( XamlSerializationHelper.ReadDouble(reader), XamlSerializationHelper.ReadDouble(reader)); collection.Add(point); } return(collection); }
private static IList <Point> DeserializeListOfPointsAndTwoBools(BinaryReader br, Byte firstByte, out bool bool1, out bool bool2) { int count; IList <Point> points; Point point; // Pack the two bools into one byte UnPackBools(firstByte, out bool1, out bool2); count = br.ReadInt32(); points = new List <Point>(count); for (int i = 0; i < count; i++) { point = new Point(XamlSerializationHelper.ReadDouble(br), XamlSerializationHelper.ReadDouble(br)); points.Add(point); } return(points); }
// Token: 0x06002278 RID: 8824 RVA: 0x000AB5E4 File Offset: 0x000A97E4 public override bool ConvertStringToCustomBinary(BinaryWriter writer, string stringValue) { return(XamlSerializationHelper.SerializeVector3D(writer, stringValue)); }
/// <summary> /// Convert a string into a compact binary representation and write it out /// to the passed BinaryWriter. /// </summary> public override bool ConvertStringToCustomBinary( BinaryWriter writer, // Writer into the baml stream string stringValue) // String to convert { return(XamlSerializationHelper.SerializePoint3D(writer, stringValue)); }