Esempio n. 1
0
 public async Task Initialize(SwapChainBackgroundPanel panel)
 {
     _vlcPlayer             = new Player(panel);
     _vlcInitializeTask     = _vlcPlayer.Initialize().AsTask();
     _vlcPlayer.MediaEnded += _vlcPlayer_MediaEnded;
     await _vlcInitializeTask;
 }
        public static void PlayVideoFullscreen(string videoUrl, bool controlsEnabled, bool tapSkipsVideo)
        {
#if NETFX_CORE
            CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                Page page = (Page)Window.Current.Content;
                SwapChainBackgroundPanel backgroundPanel = (SwapChainBackgroundPanel)page.FindName("DXSwapChainBackgroundPanel");

                MediaElement videoPlayBackElement = new MediaElement();

                videoPlayBackElement.IsFullWindow = true;
                videoPlayBackElement.Source       = new Uri(videoUrl);
                videoPlayBackElement.AreTransportControlsEnabled = controlsEnabled;

                if (tapSkipsVideo)
                {
                    videoPlayBackElement.Tapped += delegate { backgroundPanel.Children.Remove(videoPlayBackElement); };
                }
                videoPlayBackElement.MediaEnded += delegate { backgroundPanel.Children.Remove(videoPlayBackElement); };

                backgroundPanel.Children.Add(videoPlayBackElement);

                videoPlayBackElement.Play();
            });
#endif
        }
        public VideoElement(string videoUrl, bool controlsEnabled, bool tapSkipsVideo, bool autoPlay)
        {
#if NETFX_CORE
            CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                Page page        = (Page)Window.Current.Content;
                _backgroundPanel = (SwapChainBackgroundPanel)page.FindName("DXSwapChainBackgroundPanel");

                _mediaElement = new MediaElement();

                _mediaElement.IsFullWindow = true;
                _mediaElement.Source       = new Uri(videoUrl);
                _mediaElement.AreTransportControlsEnabled = controlsEnabled;
                _mediaElement.MediaEnded  += delegate { _backgroundPanel.Children.Remove(_mediaElement); playbackFinished = true; isPlaying = false; };
                _mediaElement.MediaOpened += delegate { isPlaying = true; mediaDuration = _mediaElement.NaturalDuration.TimeSpan.TotalSeconds; };

                if (tapSkipsVideo)
                {
                    _mediaElement.Tapped += delegate { _backgroundPanel.Children.Remove(_mediaElement); playbackFinished = true; isPlaying = false; };
                }

                if (autoPlay)
                {
                    this.Play();
                }
            });
#endif
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SwapChainPanelWrapper"/> class.
        /// </summary>
        /// <param name="bgPanel">The panel for which to create the wrapper.</param>
        public SwapChainPanelWrapper(SwapChainBackgroundPanel bgPanel)
            : this()
        {
            m_bgPanel       = bgPanel;
            m_bgPanelNative = ComObject.As <DXGI.ISwapChainBackgroundPanelNative>(m_bgPanel);

            m_bgPanel.SizeChanged += OnAnyPanel_SizeChanged;
            m_bgPanel.Loaded      += OnAnyPanel_Loaded;
            m_bgPanel.Unloaded    += OnAnyPanel_Unloaded;
        }
Esempio n. 5
0
        public D3DAppSwapChainBackgroundTarget(SwapChainBackgroundPanel panel)
        {
            this.backgroundPanel = panel;

            nativeBackgrounPanel              = ToDispose(ComObject.As <SharpDX.DXGI.ISwapChainBackgroundPanelNative>(panel));
            this.backgroundPanel.SizeChanged += (sender, args) =>
            {
                SizeChanged();
            };
        }
Esempio n. 6
0
        public App()
        {
            _inst = this;
            InitializeComponent();
            _swapPanel              = new SwapChainBackgroundPanel();
            _swapPanel.SizeChanged += OnSwapPanelSizeChanged;
            _swapPanel.Loaded      += OnSwapPanelLoaded;

            _pages = new Dictionary <Type, Page>();
            Game   = new GameCore();
        }
        /// <summary>
        /// Initializes a new <see cref="SwapChainBackgroundPanelTarget"/> instance
        /// </summary>
        /// <param name="panel">The <see cref="SwapChainBackgroundPanel"/> to render to</param>
        public SwapChainBackgroundPanelTarget(SwapChainBackgroundPanel panel)
        {
            this.panel = panel;

            // Gets the native panel
            nativePanel = ComObject.As <ISwapChainBackgroundPanelNative>(panel);

            // Register event on Window Size Changed
            // So that resources dependent size can be resized
            Window.Current.CoreWindow.SizeChanged += CoreWindow_SizeChanged;
        }
Esempio n. 8
0

        
        public void SetGrid(object grid)
        {
#if WINDOWS_PHONE
            baseGrid = (DrawingSurfaceBackgroundGrid)grid;
#elif NETFX_CORE
            Debug.WriteLine(grid);
            backPanel = (SwapChainBackgroundPanel)grid;
#else
            //Unity or some such
            return;
#endif
        }
Esempio n. 10
0
        public static void Init(string launchParameters, CoreWindow window, SwapChainBackgroundPanel swapChainBackgroundPanel)
        {
            if (state != EngineState.UnInitialized)
            {
                game = XamlGame <RGSSGame> .Create(launchParameters, window, swapChainBackgroundPanel);

                game.IsFixedTimeStep = true;
                game.GameControler   = (GameControler.CreateControler(game));
            }
            else
            {
                throw new Exception("RGSSEngine has already been initialized");
            }
        }
Esempio n. 11
0
        internal override void Initialize(GameContext windowContext)
        {
            if (windowContext != null)
            {
                swapChainBackgroundPanel = windowContext.Control as SwapChainBackgroundPanel;
                if (swapChainBackgroundPanel == null)
                {
                    throw new NotSupportedException(string.Format("Unsupported window context [{0}]. Only  SwapChainBackgroundPanel", windowContext.Control.GetType().FullName));
                }

                //clientBounds = new DrawingRectangle(0, 0, (int)swapChainBackgroundPanel.ActualWidth, (int)swapChainBackgroundPanel.ActualHeight);
                swapChainBackgroundPanel.SizeChanged += swapChainBackgroundPanel_SizeChanged;
            }
        }
Esempio n. 12
0
        public void InitializeComponent()
        {
            Application.LoadComponent(this, new System.Uri("ms-resource:Files/MainPage.xaml"));

            App = (DXInteropApp)Application.Current;

            SwapChainBackgroundPanel customSCBP = this.SetupSCBPTree();

            this.Content = customSCBP;

            // On SurfaceContentsLost we create a new device, set a new SC, and recover SIS/VSIS contents, but apperentlly the device will not be ready for the next CompositionTarget_Rendering.
            CompositionTarget.SurfaceContentsLost += new System.EventHandler <object>(CompositionTarget_SurfaceContentsLost);
            CompositionTarget.Rendering           += new System.EventHandler <object>(CompositionTarget_Rendering);

            DXInteropApp.WindowList.Add(Window.Current.CoreWindow);
            Window.Current.Activated += new WindowActivatedEventHandler(Current_Window_Activated);
        }
Esempio n. 13
0
        private void BindSwapChainBackgroundPanel(SwapChainBackgroundPanel panel)
        {
            if (BackgroundPanel != null)
            {
                throw new Exception("Background panel is already set");
            }
            if (panel == null)
            {
                throw new ArgumentNullException("panel");
            }
            if (_swap == null)
            {
                throw new Exception("Device must be initialised first");
            }

            _panel = panel;
            SetChainToPanel();
        }
Esempio n. 14
0
        /// <summary>
        /// Creates your Game class initializing it to work within a XAML application window.
        /// </summary>
        /// <param name="launchParameters">The command line arguments from launch.</param>
        /// <param name="window">The core window object.</param>
        /// <param name="swapChainBackgroundPanel">The XAML SwapChainBackgroundPanel to which we render the scene and recieve input events.</param>
        /// <returns></returns>
        static public T Create(string launchParameters, CoreWindow window, SwapChainBackgroundPanel swapChainBackgroundPanel)
        {
            if (launchParameters == null)
            {
                throw new NullReferenceException("The launch parameters cannot be null!");
            }
            if (window == null)
            {
                throw new NullReferenceException("The window cannot be null!");
            }
            if (swapChainBackgroundPanel == null)
            {
                throw new NullReferenceException("The swap chain panel cannot be null!");
            }

            // Save any launch parameters to be parsed by the platform.
            MetroGamePlatform.LaunchParameters = launchParameters;

            // Setup the window class.
            MetroGameWindow.Instance.Initialize(window, swapChainBackgroundPanel, MetroGamePlatform.TouchQueue);

            // Construct the game.
            var game = new T();

            // Set the swap chain panel on the graphics mananger.
            if (game.graphicsDeviceManager == null)
            {
                throw new NullReferenceException("You must create the GraphicsDeviceManager in the Game constructor!");
            }
            game.graphicsDeviceManager.SwapChainBackgroundPanel = swapChainBackgroundPanel;

            // Start running the game.
            game.Run(GameRunBehavior.Asynchronous);

#if WINDOWS_PHONE81
            HardwareButtons.BackPressed += HardwareButtons_BackPressed;
#endif

            // Return the created game object.
            return(game);
        }
        /// <summary>
        /// Display the keyboard input panel
        /// </summary>
        /// <param name="graphics">The game's GraphicsDeviceManager (usually the _graphics object)</param>
        /// <param name="callbackfnc">A function to call once the keyboard panel has been used</param>
        /// <param name="title">The title for the panel</param>
        /// <param name="body">The body text for the panel</param>
        /// <param name="initialValue">The initial user text to display in the panel</param>
        public static void BeginShowKeyboardInput(GraphicsDeviceManager graphics, KeyboardInputCallback callbackfnc, string title, string body, string initialValue)
        {
            // Don't do anything if the keyboard input panel is already displayed
            if (KeyboardInputIsVisible)
            {
                return;
            }

            // Remember that the input panel is now being displayed
            KeyboardInputIsVisible = true;
            // Remember the callback function
            _keyboardInputCallbackFnc = callbackfnc;

#if WINDOWS_PHONE
            BeginShowKeyboardInput_WP(title, body, initialValue);
#else
            // Store the game's SwapChainPanel
            _parent = graphics.SwapChainPanel;
            // Show the keyboard 'popup'
            BeginShowKeyboardInput_Win8(title, body, initialValue);
#endif
        }
Esempio n. 16
0
 public GameRenderer(SwapChainBackgroundPanel panel)
     : base(panel)
 {
 }
Esempio n. 17
0
        static public T Create(ProtocolActivatedEventArgs args, CoreWindow window, SwapChainBackgroundPanel swapChainBackgroundPanel)
        {
            MetroGamePlatform.PreviousExecutionState = args.PreviousExecutionState;

            return(Create(args.Uri.AbsoluteUri, window, swapChainBackgroundPanel));
        }
Esempio n. 18
0
        /// <summary>
        /// Preserves the previous execution state in MetroGamePlatform and returns the constructed game object initialized with the given window.
        /// </summary>
        /// <param name="args">The command line arguments from launch.</param>
        /// <param name="window">The core window object.</param>
        /// <param name="swapChainBackgroundPanel">The XAML SwapChainBackgroundPanel to which we render the scene and recieve input events.</param>
        /// <returns></returns>
        static public T Create(LaunchActivatedEventArgs args, CoreWindow window, SwapChainBackgroundPanel swapChainBackgroundPanel)
        {
            MetroGamePlatform.PreviousExecutionState = args.PreviousExecutionState;

            return(Create(args.Arguments, window, swapChainBackgroundPanel));
        }
Esempio n. 19
0
        public ApplicationPage(string applicationID, string unitID, ApplicationAdSize adSize, ApplicationAdGravity adGravity, bool supportAds)
        {
            swapChainPanel = new SwapChainBackgroundPanel();

            if (supportAds)
            {
                adControl = new AdControl();
                adControl.ApplicationId = applicationID;
                adControl.AdUnitId      = unitID;

                adControl.IsEnabled  = false;
                adControl.Visibility = Visibility.Collapsed;

                switch (adSize)
                {
                case ApplicationAdSize.Sqaure_250x250:
                    adControl.Width  = 250;
                    adControl.Height = 250;
                    break;

                default:
                    Debug.ThrowError("ApplicationPage", "Unsuported Ad size");
                    break;
                }

                switch (adGravity)
                {
                case ApplicationAdGravity.BottomLeft:
                    adControl.HorizontalAlignment = HorizontalAlignment.Left;
                    adControl.VerticalAlignment   = VerticalAlignment.Bottom;
                    break;

                case ApplicationAdGravity.BottomRight:
                    adControl.HorizontalAlignment = HorizontalAlignment.Right;
                    adControl.VerticalAlignment   = VerticalAlignment.Bottom;
                    break;

                case ApplicationAdGravity.BottomCenter:
                    adControl.HorizontalAlignment = HorizontalAlignment.Center;
                    adControl.VerticalAlignment   = VerticalAlignment.Top;
                    break;

                case ApplicationAdGravity.TopLeft:
                    adControl.HorizontalAlignment = HorizontalAlignment.Left;
                    adControl.VerticalAlignment   = VerticalAlignment.Top;
                    break;

                case ApplicationAdGravity.TopRight:
                    adControl.HorizontalAlignment = HorizontalAlignment.Right;
                    adControl.VerticalAlignment   = VerticalAlignment.Top;
                    break;

                case ApplicationAdGravity.TopCenter:
                    adControl.HorizontalAlignment = HorizontalAlignment.Center;
                    adControl.VerticalAlignment   = VerticalAlignment.Top;
                    break;

                default:
                    Debug.ThrowError("ApplicationPage", "Unsuported Ad gravity");
                    break;
                }

                swapChainPanel.Children.Add(adControl);
            }

            base.Content = swapChainPanel;
            ((XAMLApplication)OS.CurrentApplication).SwapChainPanel = swapChainPanel;
        }
Esempio n. 20
0
        public static void Create(CCApplicationDelegate appDelegate, LaunchActivatedEventArgs args, Windows.UI.Core.CoreWindow coreWindow, SwapChainBackgroundPanel swapChainBackgroundPanel)
        {
            var game = MonoGame.Framework.XamlGame <CCGame> .Create(args, coreWindow, swapChainBackgroundPanel);

            foreach (var component in game.Components)
            {
                if (component is CCApplication)
                {
                    var instance = component as CCApplication;
                    instance.ApplicationDelegate = appDelegate;
                }
            }
        }
Esempio n. 21
0
 private XamlGraphicsDevice()
 {
     _panel      = null;
     _ready      = false;
     ClearColour = Color.Magenta;
 }
 /// <summary>
 /// Attaches the renderer to the given SwapChainBackgroundPanel.
 /// </summary>
 /// <param name="targetPanel">The target panel to attach to.</param>
 public void Attach(SwapChainBackgroundPanel targetPanel)
 {
     this.AttachInternal(new SwapChainPanelWrapper(targetPanel));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SeeingSharpPanelPainter"/> class.
 /// </summary>
 /// <param name="targetPanel">The target panel.</param>
 public SeeingSharpPanelPainter(SwapChainBackgroundPanel targetPanel)
     : this()
 {
     this.Attach(targetPanel);
 }
Esempio n. 24
0
 public Player(SwapChainBackgroundPanel panel)
 {
 }