Ejemplo n.º 1
0
        public void Save(MainViewModel viewModel)
        {
            GestSpaceData space = new GestSpaceData();
            foreach(var tileVm in viewModel.Tiles.Where(t => !t.IsUnused))
            {
                var tile = new TileData();
                space.Tiles.Add(tile);
                if(!tileVm.TakeSuggestedName)
                {
                    tile.ForcedName = tileVm.Description;
                }
                tile.X = (int)tileVm.Position.X;
                tile.Y = (int)tileVm.Position.Y;
                if(tileVm.SelectedPresenterTemplate != null)
                    tile.PresenterTemplate = tileVm.SelectedPresenterTemplate.Description;
                if(tileVm.SelectedGestureTemplate != null)
                    tile.GestureTemplate = tileVm.SelectedGestureTemplate.Name;

                tile.Program = tileVm.FastContext;
                foreach(var evtVm in tileVm.Events)
                {
                    var evt = new EventData();
                    tile.Events.Add(evt);
                    evt.Name = evtVm.Name;
                    if(evtVm.Command != null)
                        evt.Command = evtVm.Command.Script;
                }
            }
            if(viewModel.CurrentTile != null)
            {
                space.LastX = (int)viewModel.CurrentTile.Position.X;
                space.LastY = (int)viewModel.CurrentTile.Position.Y;
            }
            Save(space);
        }
Ejemplo n.º 2
0
 private void Save(GestSpaceData space)
 {
     var store = GetStore();
     using(var fs = store.OpenFile("spacedata", System.IO.FileMode.Create))
     {
         DataContractSerializer seria = new DataContractSerializer(typeof(GestSpaceData));
         seria.WriteObject(fs,space);
     }
 }