public void CopyFrom(SimpleSkylineGeneratorSettings source) { try { _updatesLocked = true; this.Background = source.Background.Clone(); this.Buildings = new BuildingStyleCollection(); foreach (BuildingStyle building in source.Buildings) { this.Buildings.Add(building.Clone()); } this.Size = source.Size; this.MaximumBuildingSize = source.MaximumBuildingSize; this.MinimumBuildingSize = source.MinimumBuildingSize; this.Density = source.Density; this.LightingDensity = source.LightingDensity; this.Horizon = source.Horizon; this.Stars = source.Stars.Clone(); this.Seed = source.Seed; } finally { _updatesLocked = false; } this.OnPropertyChanged("Seed"); }
private void SavePreset(SimpleSkylineGeneratorSettings settings, string fileName) { try { using (StreamWriter stream = File.CreateText(fileName)) { JsonSerializer serializer; serializer = new JsonSerializer { Formatting = Formatting.Indented }; serializer.Serialize(stream, settings); this.LoadPresets(); } } catch (Exception ex) { MessageBox.Show(string.Format("Failed to save preset. {0}", ex.GetBaseException().Message), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }