private void buttonReset_Click(object sender, EventArgs e) { // Remove the old particle system... _scene.Positionables.Remove(_particleSystem); _particleSystem.Dispose(); // ... and replace it with a new one using the same _preset _particleSystem = new CpuParticleSystem(_preset); _scene.Positionables.Add(_particleSystem); }
//--------------------// #region Handlers /// <inheritdoc/> protected override void OnInitialize() { #region File handling if (Path.IsPathRooted(FilePath)) { _fullPath = FilePath; if (!_overwrite && File.Exists(_fullPath)) { // Load existing file Log.Info("Load file: " + _fullPath); _preset = XmlStorage.LoadXml <CpuParticlePreset>(_fullPath); } else { // Create new file Log.Info("Create file: " + _fullPath); _preset = new CpuParticlePreset(); _preset.SaveXml(_fullPath); } } else { // File name only? Might not save to same dir loaded from! Log.Info("Load file: " + FilePath); _preset = CpuParticlePreset.FromContent(FilePath); _fullPath = ContentManager.CreateFilePath("Graphics/CpuParticleSystem", FilePath); } #endregion // Initialize engine renderPanel.Setup(); // Setup scene _particleSystem = new CpuParticleSystem(_preset); _scene = new Scene { Positionables = { _particleSystem } }; renderPanel.Engine.Views.Add(new View(_scene, Camera) { BackgroundColor = Color.Black }); base.OnInitialize(); }