Esempio n. 1
0
        /// <summary>
        /// Handles selection of files in the game explorer, displaying them to the user and routing
        /// whatever rendering functionality the file needs to the viewport.
        /// </summary>
        /// <param name="page">The <see cref="GamePage"/> in which the event originated.</param>
        /// <param name="fileReference">The file reference to load.</param>
        private async void OnFileLoadRequested(GamePage page, FileReference fileReference)
        {
            WarcraftFileType referencedType = fileReference.GetReferencedFileType();

            switch (referencedType)
            {
            case WarcraftFileType.BinaryImage:
            {
                this.FileLoadingCancellationSource.Cancel();
                this.FileLoadingCancellationSource = new CancellationTokenSource();

                await DisplayRenderableFile
                (
                    page,
                    fileReference,
                    DataLoadingRoutines.LoadBinaryImage,
                    DataLoadingRoutines.CreateRenderableBinaryImage,
                    ControlPage.Image,
                    this.FileLoadingCancellationSource.Token
                );

                break;
            }

            case WarcraftFileType.WorldObjectModel:
            {
                this.FileLoadingCancellationSource.Cancel();
                this.FileLoadingCancellationSource = new CancellationTokenSource();

                await DisplayRenderableFile
                (
                    page,
                    fileReference,
                    DataLoadingRoutines.LoadWorldModel,
                    DataLoadingRoutines.CreateRenderableWorldModel,
                    ControlPage.Model,
                    this.FileLoadingCancellationSource.Token
                );

                break;
            }

            case WarcraftFileType.WorldObjectModelGroup:
            {
                this.FileLoadingCancellationSource.Cancel();
                this.FileLoadingCancellationSource = new CancellationTokenSource();

                await DisplayRenderableFile
                (
                    page,
                    fileReference,
                    DataLoadingRoutines.LoadWorldModelGroup,
                    DataLoadingRoutines.CreateRenderableWorldModel,
                    ControlPage.Model,
                    this.FileLoadingCancellationSource.Token
                );

                break;
            }

            case WarcraftFileType.GIFImage:
            case WarcraftFileType.PNGImage:
            case WarcraftFileType.JPGImage:
            {
                this.FileLoadingCancellationSource.Cancel();
                this.FileLoadingCancellationSource = new CancellationTokenSource();

                await DisplayRenderableFile
                (
                    page,
                    fileReference,
                    DataLoadingRoutines.LoadBitmapImage,
                    DataLoadingRoutines.CreateRenderableBitmapImage,
                    ControlPage.Image,
                    this.FileLoadingCancellationSource.Token
                );

                break;
            }

            case WarcraftFileType.WaveAudio:
            case WarcraftFileType.MP3Audio:
            {
                AudioManager.UnregisterSource(this.GlobalAudio);

                this.GlobalAudio = AudioSource.CreateNew();
                await this.GlobalAudio.SetAudioAsync(fileReference);

                AudioManager.RegisterSource(this.GlobalAudio);

                this.GlobalAudio.Play();
                break;
            }
            }
        }