internal TrackItemSound(STFReader stf, TrackItem[] trItems) { stf.MustMatchBlockStart(); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("soundsource", () => { SoundSources.Add(new WorldSoundSource(stf)); }), new STFReader.TokenProcessor("soundregion", () => { SoundRegions.Add(new WorldSoundRegion(stf, trItems)); }), }); }
internal static void Terminate() { for (int loop = 0; loop < 3; loop++) { SoundSources.DestroyAll(); Cursors.DestroyAll(); Texture2Ds.DestroyAll(); CubemapTextures.DestroyAll(); Fonts.DestroyAll(); Chip2Ds.DestroyAll(); Shader2Ds.DestroyAll(); Shader3Ds.DestroyAll(); Material2Ds.DestroyAll(); Material3Ds.DestroyAll(); MaterialPropertyBlocks.DestroyAll(); ImagePackages.DestroyAll(); Effects.DestroyAll(); Meshs.DestroyAll(); Deformers.DestroyAll(); Models.DestroyAll(); MassModels.DestroyAll(); Terrain3Ds.DestroyAll(); KeyframeAnimations.DestroyAll(); AnimationSources.DestroyAll(); Scenes.DestroyAll(); Layer2Ds.DestroyAll(); Object2Ds.DestroyAll(); Layer3Ds.DestroyAll(); Object3Ds.DestroyAll(); PostEffects.DestroyAll(); Transitions.DestroyAll(); StaticFiles.DestroyAll(); StreamFiles.DestroyAll(); Shapes.DestroyAll(); //Profilers.DestroyAll(); Collector.Collect(); System.GC.Collect(); System.GC.WaitForPendingFinalizers(); System.GC.Collect(); Collector.Collect(); } }
internal static void Update() { if (Collector.Collect()) { SoundSources.Collect(); Cursors.Collect(); Texture2Ds.Collect(); CubemapTextures.Collect(); Fonts.Collect(); Chip2Ds.Collect(); Shader2Ds.Collect(); Shader3Ds.Collect(); Material2Ds.Collect(); Material3Ds.Collect(); MaterialPropertyBlocks.Collect(); ImagePackages.Collect(); MediaPlayers.Collect(); Effects.Collect(); Meshs.Collect(); Deformers.Collect(); Models.Collect(); MassModels.Collect(); Terrain3Ds.Collect(); KeyframeAnimations.Collect(); AnimationSources.Collect(); AnimationClips.Collect(); Scenes.Collect(); Layer2Ds.Collect(); Object2Ds.Collect(); Layer3Ds.Collect(); Object3Ds.Collect(); PostEffects.Collect(); Transitions.Collect(); StaticFiles.Collect(); StreamFiles.Collect(); Shapes.Collect(); Collider2Ds.Collect(); } }
internal static void Terminate() { for (int loop = 0; loop < 3; loop++) { SoundSources.DestroyAll(); Texture2Ds.DestroyAll(); CubemapTextures.DestroyAll(); Shader2Ds.DestroyAll(); Material2Ds.DestroyAll(); Effects.DestroyAll(); Meshs.DestroyAll(); Deformers.DestroyAll(); Models.DestroyAll(); KeyframeAnimations.DestroyAll(); AnimationSources.DestroyAll(); Scenes.DestroyAll(); Layer2Ds.DestroyAll(); Object2Ds.DestroyAll(); Layer3Ds.DestroyAll(); Object3Ds.DestroyAll(); PostEffects.DestroyAll(); //Profilers.DestroyAll(); Collector.Collect(); System.GC.Collect(); System.GC.WaitForPendingFinalizers(); System.GC.Collect(); Collector.Collect(); } }
public MainWindowViewModel() { #region ChangeNumberOfCubesCommand ChangeNumberOfCubesCommand = new RelayCommand<EventArgs>(e => { Status = "Changing number of cubes"; var args = e as RoutedPropertyChangedEventArgs<double>; if (args != null) { var numToChange = Math.Abs(Convert.ToInt32(CubeViewModels.Count - args.NewValue)); if (args.NewValue < CubeViewModels.Count) // removing cubes { for (var i = 0; i < numToChange; i++) { CubeViewModels.RemoveAt(CubeViewModels.Count - 1); } NeighborCalculator.CalculateNeighbors(CubeViewModels); } else if (args.NewValue > CubeViewModels.Count) // adding cubes { AddNewCubes(numToChange); Status = ReadyStatus; SnapToGridCommand.Execute(null); if (AppRunner.IsRunning) { AppRunner.App.AssociateCubes(CubeSet); } } } Status = ReadyStatus; }); #endregion #region SnapToGridCommand SnapToGridCommand = new RelayCommand(() => { Status = "Snapping to grid"; for (var i = 0; i < Math.Ceiling(CubeViewModels.Count / 4.0); i++) { for (var j = 0; j < 4; j++) { if ((i * 4) + j > CubeViewModels.Count - 1) { NeighborCalculator.CalculateNeighbors(CubeViewModels); Status = ReadyStatus; return; } CubeViewModels[(i * 4) + j].PositionX = 200 * j; CubeViewModels[(i * 4) + j].PositionY = 200 * i; } } NeighborCalculator.CalculateNeighbors(CubeViewModels); Status = ReadyStatus; }); #endregion #region LoadAFileCommand LoadAFileCommand = new RelayCommand(() => { if (AppRunner.IsRunning) { AppRunner.StopExecution(); } Status = "Select the application to run."; var openFileDialog = new OpenFileDialog { Filter = "C# Library (*.dll)|*.dll|All Files (*.*)|*.*", FilterIndex = 1, Multiselect = false }; if (openFileDialog.ShowDialog() == true) { Status = "Loading application..."; using (var fileStream = openFileDialog.File.OpenRead()) { try { AppRunner.LoadApplication(fileStream); } catch (TypeLoadException e) { Status = String.Format("Unable to load application: {0}", e.Message); } } if (AppRunner.IsLoaded) { Status = "Loading image resources..."; if (openFileDialog.File.Directory != null) { _imageSources = new ImageSources(openFileDialog.File.Directory.FullName + "/assets/images"); SoundSources = new SoundSources(openFileDialog.File.Directory.FullName + "/assets/sounds"); SoundSources.NotifyNewSound += sound => SoundSources.InitializeSound(sound, ActiveSounds, InactiveSounds); Sound.NotifyPauseAllSounds += () => SoundSources.PauseAllSounds(ActiveSounds, InactiveSounds); Sound.NotifyResumeAllSounds += () => SoundSources.ResumeAllSounds(ActiveSounds, InactiveSounds); Sound.NotifyStopAllSounds += () => SoundSources.StopAllSounds(ActiveSounds, InactiveSounds); AppRunner.App.Images = _imageSources.GetImageSet(); foreach (var cubeViewModel in CubeViewModels) { cubeViewModel.ImageSources = _imageSources; } Status = openFileDialog.File.Name + " was loaded."; AppRunner.StartExecution(CubeSet, Application.Current.MainWindow.Dispatcher, SoundSources.SoundSet); AppRunner.NotifyApplicationException += DisplayException; NotifyPropertyChanged("PauseOrResumeText"); NotifyPropertyChanged("CanPauseOrResume"); } else { Status = "Application loading failed."; } } } else { Status = "Program loader was closed."; } }); #endregion #region PauseOrResumeCommand PauseOrResumeCommand = new RelayCommand(() => { if (AppRunner.IsRunning) { AppRunner.PauseExecution(); SoundSources.PauseAllSounds(ActiveSounds, InactiveSounds); } else { AppRunner.ResumeExecution(); SoundSources.ResumeAllSounds(ActiveSounds, InactiveSounds); } NotifyPropertyChanged("PauseOrResumeText"); }); #endregion #region ChangeBackgroundCommand ChangeBackgroundCommand = new RelayCommand(() => { Status = "Changing Background"; if (BgColor == "SkyBlue") { BgColor = "Red"; } else { BgColor = "SkyBlue"; } Status = ReadyStatus; }); #endregion AppRunner = AppRunner.GetInstance(); CubeViewModels = new ObservableCollection<CubeViewModel>(); AddNewCubes(NumInitialCubes); SnapToGridCommand.Execute(null); ActiveSounds = new ObservableCollection<SoundViewModel>(); InactiveSounds = new Collection<SoundViewModel>(); Status = ReadyStatus; }