예제 #1
0
 public override void Unload()
 {
     if (PreviewElement != null)
     {
         PreviewElement.OnBeforeRemove();
     }
     VideoInfo = null;
     base.Unload();
 }
예제 #2
0
        public PreviewPresenter()
        {
            PlatformCtor();

            PreviewElement.SetBinding(DockItemPreviewElement.GeometryProperty, new Binding("Preview.Geometry")
            {
                Source = this
            });
        }
예제 #3
0
        /// <summary>
        /// Start previewing
        /// </summary>
        /// <returns></returns>
        private async Task StartPreviewAsync()
        {
            _mediaPlayer = new MediaPlayer();
            _mediaPlayer.RealTimePlayback         = true;
            _mediaPlayer.AutoPlay                 = true;
            _mediaPlayer.Source                   = MediaSource.CreateFromMediaFrameSource(_selectedFrameSource);
            _mediaPlayer.CommandManager.IsEnabled = false;
            PreviewElement.SetMediaPlayer(_mediaPlayer);
            _mediaPlayerProjection = _mediaPlayer.PlaybackSession.SphericalVideoProjection;

            // Set up the UI to preview the stream
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                if (ToggleForceSpherical.IsChecked == true)
                {
                    // force spherical projection format from UI button
                    _mediaPlayerProjection.FrameFormat = SphericalVideoFrameFormat.Equirectangular;
                    _mediaPlayerProjection.IsEnabled   = true;
                    _mediaPlayerProjection.HorizontalFieldOfViewInDegrees = 120;
                    if (_sphericalProjectionEffect != null)
                    {
                        _sphericalProjectionEffect.SphericalProjection.HorizontalFieldOfViewInDegrees = 120;
                    }
                }
                else
                {
                    _mediaPlayerProjection.IsEnabled = (_mediaPlayerProjection.FrameFormat == SphericalVideoFrameFormat.Equirectangular);
                }

                // Show vertical scroll bar for zoom
                FieldOfViewControl.Visibility = _mediaPlayerProjection.IsEnabled ?
                                                Visibility.Visible
                    : Visibility.Collapsed;

                PreviewElement.ManipulationMode = _mediaPlayerProjection.IsEnabled ?
                                                  ManipulationModes.TranslateX | ManipulationModes.TranslateY | ManipulationModes.Rotate | ManipulationModes.TranslateInertia
                    : ManipulationModes.None;

                // this check box makes sense only when spherical projection is enabled.
                ToggleRecordProjection.Visibility = _mediaPlayerProjection.IsEnabled ?
                                                    Visibility.Visible
                    : Visibility.Collapsed;

                // Prevent the device from sleeping while we run the preview
                _displayRequest.RequestActive();

                _isPreviewing = true;
            });
        }
예제 #4
0
    public void Init(Dungeon dungeon)
    {
        Addable[] addables    = dungeon.Addables;
        int       playerIndex = PLACEHOLDER_PLAYER_INDEX;

        // find player index
        for (int i = 0; i < addables.Length && playerIndex == PLACEHOLDER_PLAYER_INDEX; i++)
        {
            Addable addable = addables[i];
            if (addable.AddableType == AddableType.STATIC && addable.StaticData.TileType == TileType.PLAYER)
            {
                playerIndex = i;
            }
        }

        // find floor with player
        int[] startingFloor = null;

        Floor[] dungeonFloors = dungeon.Floors;
        for (int i = 0; i < dungeonFloors.Length && startingFloor == null; i++)
        {
            int[] indices = dungeonFloors[i].Indices;
            for (int j = 0; j < indices.Length && startingFloor == null; j++)
            {
                int index = indices[j];
                if (index == playerIndex)
                {
                    startingFloor = indices;
                }
            }
        }

        // Who submits an empty level???
        if (startingFloor != null)
        {
            // setup preview, startingFloor length should match preview
            for (int i = 0; i < startingFloor.Length; i++)
            {
                PreviewElement element = elements[i];
                int            index   = startingFloor[i];

                element.IsVisible = (index != SerializationUtil.NO_ELEMENT);
                if (index != SerializationUtil.NO_ELEMENT)
                {
                    Addable addable = addables[index];
                    Sprite  sprite  = null;
                    switch (addable.AddableType)
                    {
                    case AddableType.STATIC:
                        sprite = SpriteList.GetStatic(addable.StaticData.TileType);
                        break;

                    case AddableType.BOOSTER:
                        sprite = SpriteList.GetBooster(addable.BoosterData.SpriteID);
                        break;

                    case AddableType.ENEMY:
                        sprite = SpriteList.GetEnemy(addable.EnemyData.SpriteID);
                        break;
                    }
                    element.Sprite = sprite;
                }
            }
        }
    }