public void Load(IShapeReadonlySurface surface, Stream stream) { if (surface == null) { throw new ArgumentNullException("surface"); } if (!stream.CanRead) { throw new ArgumentException("stream"); } XmlSerializer xs = new XmlSerializer(typeof(SurfaceStoreData)); try { SurfaceStoreData data = (SurfaceStoreData)xs.Deserialize(stream); SurfaceStoreData.LoadStoredData(surface, data); } catch (Exception ex) { #if TRACE System.Diagnostics.Trace.TraceWarning("An exception occur on Loading NetWorkStudio Image: " + ex.Message); #endif surface.Source.Load(null, new Size(100, 100), null, null, null); } }
public void Load(IShapeReadonlySurface surface, Stream stream) { if (!stream.CanRead) { throw new ArgumentException("stream"); } SurfaceStoreData data; SerializationBasedStreamItemReader reader = new SerializationBasedStreamItemReader(stream); long length = stream.Length; if (length > 0) { object[] datas = reader.Read(); data = datas[0] as SurfaceStoreData; SurfaceStoreData.LoadStoredData(surface, data); if (datas.Length > 1) { surface.Source.Tag = datas[1]; } } else { surface.Source.Load(null, new Size(100, 100), null, null, null); } }
public static SurfaceStoreData CreateStoreData( IShapeSurface surface) { SurfaceStoreData result = new SurfaceStoreData(); IShapeSource src = surface.Source; // save the last ghost surface.NewGhost(ShapeType.None); result._picture = src.Background; result._size = src.Size; if (!src.NamedHatchStyle.IsEmpty) { result._namedHatchStyle = (NamedHatchStylesForXmlSerialize)src.NamedHatchStyle; } if (!src.NamedTextureStyle.IsEmpty) { result._namedTextureStyle = (NamedTextureStylesForXmlSerialize)src.NamedTextureStyle; } IList <IShape> shapes = src.Shapes; if (shapes != null && shapes.Count > 0) { result._shapes = new ShapeForXmlSerialize[shapes.Count]; for (int i = 0; i < shapes.Count; i++) { result._shapes[i] = new ShapeForXmlSerialize(shapes[i]); } } return(result); }
public void Save(IShapeSurface surface, Stream stream) { if (surface == null) { throw new ArgumentNullException("surface"); } if (!stream.CanWrite) { throw new ArgumentException("stream"); } SurfaceStoreData data = SurfaceStoreData.CreateStoreData(surface); XmlSerializer xs = new XmlSerializer(typeof(SurfaceStoreData)); xs.Serialize(stream, data); }
public void Save(IShapeSurface surface, Stream stream) { if (!stream.CanWrite) { throw new ArgumentException("stream"); } SerializationBasedStreamItemWriter writer = new SerializationBasedStreamItemWriter(stream); SurfaceStoreData data = SurfaceStoreData.CreateStoreData(surface); if (surface.Source.Tag == null) { writer.Write(data); } else { writer.Write(data, surface.Source.Tag); } }
public static void LoadStoredData( IShapeReadonlySurface surface, SurfaceStoreData data) { surface.Clear(); IShape[] shapes = null; if (data._shapes != null) { shapes = new IShape[data._shapes.Length]; IShape shape; for (int i = 0; i < data._shapes.Length; i++) { shape = data._shapes[i]; shape.Data.IsBackground = true; shapes[i] = surface.Source.Factory.Create(shape.Data); } } surface.Source.Load(data._picture, data._size, (NamedHatchStyles)data._namedHatchStyle, (NamedTextureStyles)data._namedTextureStyle, shapes); }