public Level(XElement xml) { _properties = xml.Element(@"LevelProperties").DeserializedAs <LevelProperties>( ); _layers = (from x in xml.CertainElement(@"Layers").Elements(@"Layer") select new Layer(x)).ToList( ); }
public LevelEditor() { Behaviours = new BehaviourCollection( ); const string contentRootFolder = @"c:\"; _properties = new LevelProperties { Name = "Root", Visible = true, CustomProperties = new CustomProperties(), ContentRootFolder = contentRootFolder, Version = ObjectFactory.GetInstance<IGetAssemblyInformation>( ).Version }; _previousContentRootFolder = contentRootFolder; var contentRootChanged = new ContentRootChanged(_previousContentRootFolder, contentRootFolder); ObjectFactory.GetInstance<IEventHub>().Publish(contentRootChanged); Layers = new List<LayerEditor> { new LayerEditor( this, @"Layer_0" ) } ; }
public Level( XElement xml ) { _properties = xml.Element( @"LevelProperties" ).DeserializedAs<LevelProperties>( ) ; _layers = (from x in xml.CertainElement( @"Layers" ).Elements(@"Layer") select new Layer( x )).ToList( ); }
public LevelEditor(XElement xml) { TypeLookup.Rehydrate( xml ); _properties = xml.Element( @"LevelProperties" ).DeserializedAs<LevelProperties>( ) ; _previousContentRootFolder = _properties.ContentRootFolder; if( !Directory.Exists( _properties.ContentRootFolder ) ) { string message = @"The level file has a content root folder that does not exist. It says the content root is at ""{0}"". Images specified in this level file are relative to this folder so you should change it in order to load this level file correctly. Would you like to change it?".FormatWith( _properties.ContentRootFolder ) ; if(MessageBox.Show( message, @"Content root folder not found.", MessageBoxButtons.YesNo, MessageBoxIcon.Question )==DialogResult.Yes) { var folderBrowserDialog = new Ookii.Dialogs.VistaFolderBrowserDialog( ) ; DialogResult dialogResult = folderBrowserDialog.ShowDialog( ) ; if( dialogResult == DialogResult.OK ) { _properties.ContentRootFolder=folderBrowserDialog.SelectedPath ; } } } if (_properties.ContentRootFolder != _previousContentRootFolder) { //ObjectFactory.GetInstance<IEventHub>().Publish(new ContentRootChanged(_previousContentRootFolder, _properties.ContentRootFolder)); } Behaviours = new BehaviourCollection( _properties, xml ); Layers = new List<LayerEditor>( xml.CertainElement( @"Layers" ).Elements( @"Layer" ).Select( x => LayerEditor.FromXml( this, x ) ) ) ; ActiveLayer = Layers.FirstOrDefault( ) ; }