/// <summary> /// Called when a biome is selected from the view /// </summary> private void OnBiomeSelected( BiomeModel biome ) { if ( biome != null ) { m_Context.SelectedBiome = biome; } }
/// <summary> /// Adds an existing biome to the list model /// </summary> private void OnAddBiome( BiomeModel model ) { Arguments.CheckNotNull( model, "model" ); if ( m_CurrentBiomes.Models.Contains( model ) ) { return; } m_CurrentBiomes.Models.Add( model ); m_View.SelectBiome( model, true ); }
/// <summary> /// Setup constructor /// </summary> public BiomeLatitudeRangeDistribution( BiomeModel biome, float minLatitude, float maxLatitude ) { Arguments.CheckNotNull( biome, "biome" ); if ( minLatitude > maxLatitude ) { throw new ArgumentException( "Minimum latitude cannot be greater than the maximum latitude" ); } m_Biome = biome; m_MinLatitude = minLatitude; m_MaxLatitude = maxLatitude; }
/// <summary> /// Adds a new default biome to the list model /// </summary> private void OnCreateBiome( ) { INewBiomeView newBiomeView = m_ViewFactory.CreateNewBiomeView( ); if ( !newBiomeView.ShowView( ) ) { return; } BiomeModel model = new BiomeModel( newBiomeView.BiomeName ); m_AllBiomes.Models.Add( model ); m_View.AddBiome( model, true ); }
/// <summary> /// Removes a biome from the list model /// </summary> private void OnRemoveBiome( BiomeModel model ) { Arguments.CheckNotNull( model, "model" ); if ( !m_CurrentBiomes.Models.Contains( model ) ) { return; } m_CurrentBiomes.Models.Remove( model ); m_View.SelectBiome( model, false ); }
/// <summary> /// Deletes a biome from the list model /// </summary> private void OnDeleteBiome( BiomeModel model ) { Arguments.CheckNotNull( model, "model" ); m_AllBiomes.Models.Remove( model ); if ( m_CurrentBiomes.Models.Contains( model ) ) { m_CurrentBiomes.Models.Remove( model ); m_View.RemoveBiome( model ); } if ( m_Context.SelectedBiome == model ) { m_Context.SelectedBiome = null; } }
/// <summary> /// Gets the distribution used by a specified biome in this model /// </summary> IBiomeDistribution IBiomeListDistributionModel.this[BiomeModel model] { get { return GetBiomeModelDistribution( model ); } }
/// <summary> /// Gets a biome distribution from a biome. Returns null if no distribution is associated with a biome /// </summary> private BiomeLatitudeRangeDistribution GetBiomeModelDistribution( BiomeModel model ) { Arguments.CheckNotNull( model, "model" ); foreach ( BiomeLatitudeRangeDistribution distribution in m_Distributions ) { if ( distribution.Biome == model ) { return distribution; } } return null; }
/// <summary> /// Gets a latitude range distribution from a biome model /// </summary> public BiomeLatitudeRangeDistribution this[BiomeModel model] { get { return GetBiomeModelDistribution( model ); } }
/// <summary> /// Called when a biome is selected /// </summary> private void OnBiomeSelected( BiomeModel model ) { m_TerrainTypeListController.Model = model == null ? null : model.TerrainTypes; }
/// <summary> /// Selects/deselects a biome /// </summary> /// <param name="model">Biome to select</param> /// <param name="selected">Selection/deselection flag</param> public void SelectBiome( BiomeModel model, bool selected ) { Arguments.CheckNotNull( model, "model" ); int index = biomeListBox.Items.IndexOf( model ); System.Diagnostics.Debug.Assert( index != -1 ); biomeListBox.SetItemChecked( index, selected ); }
/// <summary> /// Removes a biome from the view /// </summary> public void RemoveBiome( BiomeModel model ) { Arguments.CheckNotNull( model, "model" ); biomeListBox.Items.Remove( model ); }
/// <summary> /// Adds a biome to the view /// </summary> public void AddBiome( BiomeModel model, bool selected ) { Arguments.CheckNotNull( model, "model" ); int index = biomeListBox.Items.Add( model ); biomeListBox.SetItemChecked( index, selected ); }
/// <summary> /// Splits this distribution in two, changing this distribution in place and returning /// a new distribution representing the other area /// </summary> public IBiomeDistribution Split( BiomeModel model ) { float midLatitude = ( m_MinLatitude + m_MaxLatitude ) / 2; BiomeLatitudeRangeDistribution distribution = new BiomeLatitudeRangeDistribution( model, midLatitude, m_MaxLatitude ); m_MaxLatitude = midLatitude; OnDistributionChanged( ); return distribution; }