Esempio n. 1
0
        public SaveItemXmlWrapper ToXmlWrapper(ISaveItem param)
        {
            SaveItemXmlWrapper pxw = new SaveItemXmlWrapper();

            if (param.Layer != null)
            {
                pxw.X = param.Layer.Resolution.X;
                pxw.Y = param.Layer.Resolution.Y;
                var arr = new float[pxw.X * pxw.Y];
                for (int y = 0; y < pxw.Y; y++)
                {
                    for (int x = 0; x < pxw.X; x++)
                    {
                        var val = param.Layer[x, y];
                        if (!val.HasValue)
                        {
                            arr[pxw.X * y + x] = nullRepr;
                        }
                        else
                        {
                            arr[pxw.X * y + x] = val.Value;
                        }
                    }
                }

                //  pxw.LayerData = arr; ;
            }

            pxw.World = wc.ToXmlWrapper(param.World);

            return(pxw);
        }
Esempio n. 2
0
        public void SaveToWriter(ISaveItem si, TextWriter tw)
        {
            var           sxmlw      = saveItemConverter.ToXmlWrapper(si);
            XmlSerializer serializer = new XmlSerializer(typeof(SaveItemXmlWrapper));

            serializer.Serialize(tw, sxmlw);
        }
Esempio n. 3
0
        public void Save(ISaveItem si, FileInfo fi)
        {
            try
            {
                using (TextWriter writer = new StreamWriter(fi.FullName))
                {
                    this.SaveToWriter(si, writer);
                }
            }
            catch (Exception)
            {
                // safe way to delete file without race condition
                try
                {
                    File.Delete(fi.FullName);
                }
                catch (Exception) { }



                throw;
            }
        }
Esempio n. 4
0
 public void AddItem(ISaveItem item)
 {
     items.Add(item);
     RaisePropertyChange("Items");
 }