Esempio n. 1
0
 public static XElement ToXml(SwfRGB color)
 {
     return new XElement("Color",
         new XAttribute("red", color.Red),
         new XAttribute("green", color.Green),
         new XAttribute("blue", color.Blue));
 }
Esempio n. 2
0
 public static SwfRGB FromXml(XElement xColor)
 {
     var color = new SwfRGB();
     var xRed = xColor.Attribute("red");
     var xGreen = xColor.Attribute("green");
     var xBlue = xColor.Attribute("blue");
     color.Red = xRed != null ? byte.Parse(xRed.Value) : (byte)0;
     color.Green = xGreen != null ? byte.Parse(xGreen.Value) : (byte)0;
     color.Blue = xBlue != null ? byte.Parse(xBlue.Value) : (byte)0;
     return color;
 }
Esempio n. 3
0
        public void WriteRGBTest()
        {
            var val = new SwfRGB(0x0a, 0xff, 0x83);
            var mem = new MemoryStream();
            var writer = new SwfStreamWriter(mem);
            writer.WriteRGB(ref val);
            mem.Seek(0, SeekOrigin.Begin);

            Assert.AreEqual(0x0a, mem.ReadByte(), "Byte 0");
            Assert.AreEqual(0xff, mem.ReadByte(), "Byte 1");
            Assert.AreEqual(0x83, mem.ReadByte(), "Byte 2");

            Assert.AreEqual(mem.Length, mem.Position, "Should reach end of the stream");
        }
Esempio n. 4
0
 public static void AreEqual(SwfRGB expected, SwfRGB actual, string message)
 {
     Assert.AreEqual(expected.Red, actual.Red, message + ": Red");
     Assert.AreEqual(expected.Green, actual.Green, message + ": Green");
     Assert.AreEqual(expected.Blue, actual.Blue, message + ": Blue");
 }