Ejemplo n.º 1
0
        /// <summary>
        /// Loads landscape from a file.
        /// </summary>
        /// <param name="file"> the file to be read.</param>
        /// <returns></returns>
        public async Task Load(StorageFile file)
        {
            if (file != null)
            {
                string xml = await FileIO.ReadTextAsync(file);

                //loading
                try {
                    LandscapeBuilder lb = new LandscapeBuilder {
                        XML = xml
                    };
                    BuilderModels.Clear();
                    foreach (string key in lb.Builders.Keys)
                    {
                        BuilderModel model = new BuilderModel(lb.Builders[key])
                        {
                            ID = key
                        };
                        BuilderModels.Add(model);
                    }
                    await Output.SetAsync("File was loaded sucessfully.");
                } catch (Exception) {
                    await Output.SetAsync("Unable to deserialize the file.");
                } finally { }
            }
            else
            {
                //cancelled
            }
        }