Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
 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);
 }