Esempio n. 1
0
        internal override void Initialize(GameContext gameContext)
        {
            this.GameContext = gameContext;

            gameForm = (OpenTK.GameWindow)gameContext.Control;
            nativeWindow = new WindowHandle(AppContextType.DesktopOpenTK, gameForm);

            // Setup the initial size of the window
            var width = gameContext.RequestedWidth;
            if (width == 0)
            {
                width = gameForm.Width;
            }

            var height = gameContext.RequestedHeight;
            if (height == 0)
            {
                height = gameForm.Height;
            }

            gameForm.ClientSize = new System.Drawing.Size(width, height);

            gameForm.MouseEnter += GameWindowForm_MouseEnter;
            gameForm.MouseLeave += GameWindowForm_MouseLeave;

            gameForm.Resize += OnClientSizeChanged;
        }
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
			if(Game == null)
				throw new InvalidOperationException("Please set 'Game' to a valid instance of Game before calling this method.");
				
            var bounds = UIScreen.MainScreen.Bounds;

            // create the game main windows
            MainWindow = new UIWindow(bounds);

            // create the paradox game view 
            var paradoxGameView = new iOSParadoxView((RectangleF)bounds) {ContentScaleFactor = UIScreen.MainScreen.Scale};

            // create the view controller used to display the paradox game
            var paradoxGameController = new ParadoxGameController { View = paradoxGameView };

            // create the game context
            var gameContext = new GameContext(MainWindow, paradoxGameView, paradoxGameController);

            // Force fullscreen
            UIApplication.SharedApplication.SetStatusBarHidden(true, false);

            // Added UINavigationController to switch between UIViewController because the game is killed if the FinishedLaunching (in the AppDelegate) method doesn't return true in 10 sec.
            var navigationController = new UINavigationController {NavigationBarHidden = true};
            navigationController.PushViewController(gameContext.GameViewController, false);
            MainWindow.RootViewController = navigationController;

            // launch the main window
            MainWindow.MakeKeyAndVisible();

            // launch the game
            Game.Run(gameContext);

            return Game.IsRunning;
        }
Esempio n. 3
0
        internal override void Initialize(GameContext gameContext)
        {
            GameContext = gameContext;

            paradoxGameForm = (AndroidParadoxGameView)gameContext.Control;
            nativeWindow = new WindowHandle(AppContextType.Android, paradoxGameForm);

            paradoxGameForm.Load += gameForm_Resume;
            paradoxGameForm.OnPause += gameForm_OnPause;
            paradoxGameForm.Unload += gameForm_Unload;
            paradoxGameForm.RenderFrame += gameForm_RenderFrame;

            // Setup the initial size of the window
            var width = gameContext.RequestedWidth;
            if (width == 0)
            {
                width = paradoxGameForm.Width;
            }

            var height = gameContext.RequestedHeight;
            if (height == 0)
            {
                height = paradoxGameForm.Height;
            }

            // Transmit requested back buffer and depth stencil formats to OpenTK
            paradoxGameForm.RequestedBackBufferFormat = gameContext.RequestedBackBufferFormat;
            paradoxGameForm.RequestedDepthStencilFormat = PixelFormat.None;
            paradoxGameForm.RequestedGraphicsProfile = gameContext.RequestedGraphicsProfile;

            paradoxGameForm.Size = new Size(width, height);

            //paradoxGameForm.Resize += OnClientSizeChanged;
        }
Esempio n. 4
0
        internal override void Initialize(GameContext gameContext)
        {
            GameContext = gameContext;

            gameForm = gameContext.GameView;
            nativeWindow = new WindowHandle(AppContextType.iOS, gameForm);

            gameForm.Load += gameForm_Load;
            gameForm.Unload += gameForm_Unload;
            gameForm.RenderFrame += gameForm_RenderFrame;
            
            // get the OpenGL ES version
            var contextAvailable = false;
            foreach (var version in OpenGLUtils.GetGLVersions(gameContext.RequestedGraphicsProfile))
            {
                var contextRenderingApi = MajorVersionTOEAGLRenderingAPI(version);
                EAGLContext contextTest = null;
                try
                {
                    contextTest = new EAGLContext(contextRenderingApi);

                    // delete extra context
                    if (contextTest != null)
                        contextTest.Dispose();

                    gameForm.ContextRenderingApi = contextRenderingApi;
                    contextAvailable = true;
                }
                catch (Exception)
                {
                    // TODO: log message
                }
            }

            if (!contextAvailable)
                throw new Exception("Graphics context could not be created.");

            gameForm.LayerColorFormat = MonoTouch.OpenGLES.EAGLColorFormat.RGBA8;
            //gameForm.LayerRetainsBacking = false;

            // Setup the initial size of the window
            var width = gameContext.RequestedWidth;
            if (width == 0)
            {
                width = (int)(gameForm.Size.Width * gameForm.ContentScaleFactor);
            }

            var height = gameContext.RequestedHeight;
            if (height == 0)
            {
                height = (int)(gameForm.Size.Height * gameForm.ContentScaleFactor);
            }

            gameForm.Size = new Size(width, height);

            //gameForm.Resize += OnClientSizeChanged;
        }
Esempio n. 5
0
        private void InitializeImpl()
        {
            if (gameContext == null)
            {
                gameContext = game.Context;
                gameContext.GameView.AddSubview(overlayView);

                NSNotificationCenter.DefaultCenter.AddObserver(UIDevice.OrientationDidChangeNotification, OnScreenRotated);

                UpdateOverlayAndEditBarLayout();
            }
        }
Esempio n. 6
0
        public void InitializeFromOpenTK(GameContext gameContext)
        {
            gameWindow = (OpenTK.GameWindow)gameContext.Control;

            gameWindow.Keyboard.KeyDown += Keyboard_KeyDown;
            gameWindow.Keyboard.KeyUp += Keyboard_KeyUp;
            gameWindow.Mouse.ButtonDown += Mouse_ButtonDown;
            gameWindow.Mouse.ButtonUp += Mouse_ButtonUp;
            gameWindow.Mouse.Move += Mouse_Move;
            gameWindow.Resize += GameWindowOnResize;

            GameWindowOnResize(null, EventArgs.Empty);
        }
Esempio n. 7
0
        internal override void Initialize(GameContext gameContext)
        {
            GameContext = gameContext;

            gameForm = gameContext.GameView;
            nativeWindow = new WindowHandle(AppContextType.iOS, gameForm);

            gameForm.Load += gameForm_Load;
            gameForm.Unload += gameForm_Unload;
            gameForm.RenderFrame += gameForm_RenderFrame;
            
            // get the OpenGL ES version
            var contextAvailable = false;
            foreach (var version in OpenGLUtils.GetGLVersions(gameContext.RequestedGraphicsProfile))
            {
                var contextRenderingApi = MajorVersionTOEAGLRenderingAPI(version);
                EAGLContext contextTest = null;
                try
                {
                    contextTest = new EAGLContext(contextRenderingApi);

                    // delete extra context
                    if (contextTest != null)
                        contextTest.Dispose();

                    gameForm.ContextRenderingApi = contextRenderingApi;
                    contextAvailable = true;
                    break;
                }
                catch (Exception)
                {
                    // TODO: log message
                }
            }

            if (!contextAvailable)
                throw new Exception("Graphics context could not be created.");

            gameForm.LayerColorFormat = EAGLColorFormat.RGBA8;
            //gameForm.LayerRetainsBacking = false;
        }
Esempio n. 8
0
        internal override void Initialize(GameContext gameContext)
        {
            this.GameContext = gameContext;

            Control = (Control)gameContext.Control;

            // Setup the initial size of the window
            var width = gameContext.RequestedWidth;
            if (width == 0)
            {
                width = Control is Form ? GraphicsDeviceManager.DefaultBackBufferWidth : Control.ClientSize.Width;
            }

            var height = gameContext.RequestedHeight;
            if (height == 0)
            {
                height = Control is Form ? GraphicsDeviceManager.DefaultBackBufferHeight : Control.ClientSize.Height;
            }

            windowHandle = new WindowHandle(AppContextType.Desktop, Control);

            Control.ClientSize = new System.Drawing.Size(width, height);

            Control.MouseEnter += GameWindowForm_MouseEnter;
            Control.MouseLeave += GameWindowForm_MouseLeave;

            form = Control as Form;
            var gameForm = Control as GameForm;
            if (gameForm != null)
            {
                //gameForm.AppActivated += OnActivated;
                //gameForm.AppDeactivated += OnDeactivated;
                gameForm.UserResized += OnClientSizeChanged;
            }
            else
            {
                Control.Resize += OnClientSizeChanged;
            }
        }
Esempio n. 9
0
 internal override bool CanHandle(GameContext gameContext)
 {
     return gameContext.ContextType == AppContextType.Desktop;
 }
 internal override bool CanHandle(GameContext windowContext)
 {
     return windowContext.ContextType == AppContextType.WindowsRuntime;
 }
Esempio n. 11
0
 internal abstract void Initialize(GameContext gameContext);
Esempio n. 12
0
 /// <summary>
 /// Initializes the GameWindow with the specified window context.
 /// </summary>
 /// <param name="gameContext">The window context.</param>
 internal abstract bool CanHandle(GameContext gameContext);
Esempio n. 13
0
        private void SetupGameViewAndGameContext()
        {
            // Set the main view of the Game
            SetContentView(Resource.Layout.Game);
            mainLayout = FindViewById<RelativeLayout>(Resource.Id.GameViewLayout);
            mainLayout.AddView(gameView);

            // Create the Game context
            GameContext = new GameContext(gameView, FindViewById<RelativeLayout>(Resource.Id.EditTextLayout));
        }
 internal override bool CanHandle(GameContext windowContext)
 {
     return(windowContext.ContextType == AppContextType.WindowsRuntime);
 }
        internal override void Initialize(GameContext windowContext)
        {
            if (windowContext != null)
            {
                swapChainPanel = windowContext.Control as SwapChainPanel;
                if (swapChainPanel == null)
                {
                    throw new NotSupportedException(string.Format("Unsupported window context [{0}]. Only SwapChainPanel",  windowContext.Control.GetType().FullName));
                }
                windowHandle = new WindowHandle(AppContextType.WindowsRuntime, swapChainPanel);

                //clientBounds = new DrawingRectangle(0, 0, (int)swapChainPanel.ActualWidth, (int)swapChainPanel.ActualHeight);
                swapChainPanel.SizeChanged += swapChainPanel_SizeChanged;
                swapChainPanel.CompositionScaleChanged += swapChainPanel_CompositionScaleChanged;
            }
        }
Esempio n. 16
0
        public void Run(GameContext gameContext)
        {
            gameWindow = CreateWindow(gameContext);

            // Register on Activated 
            gameWindow.GameContext = gameContext;
            gameWindow.Activated += OnActivated;
            gameWindow.Deactivated += OnDeactivated;
            gameWindow.InitCallback = OnInitCallback;
            gameWindow.RunCallback = OnRunCallback;

            var windowCreated = WindowCreated;
            if (windowCreated != null)
            {
                windowCreated(this, EventArgs.Empty);
            }

            gameWindow.Run();
        }
Esempio n. 17
0
 internal override bool CanHandle(GameContext gameContext)
 {
     return gameContext.ContextType == AppContextType.Android;
 }
Esempio n. 18
0
 internal override bool CanHandle(GameContext gameContext)
 {
     return(gameContext.ContextType == AppContextType.iOS);
 }
        private void InitializeFromWindowsWpf(GameContext uiContext)
        {
            var uiControlWpf = (Window)uiContext.Control;

            var inputElement = uiControlWpf;

            BindRawInputKeyboard(uiControl);
            uiControlWpf.LostFocus += (_, e) => OnUiControlLostFocus();
            uiControlWpf.Deactivated += (_, e) => OnUiControlLostFocus();
            uiControlWpf.MouseMove += (_, e) => OnMouseMoveEvent(PointToVector2(e.GetPosition(inputElement)));
            uiControlWpf.MouseDown += (_, e) => OnMouseInputEvent(PointToVector2(e.GetPosition(inputElement)), ConvertMouseButton(e.ChangedButton), InputEventType.Down);
            uiControlWpf.MouseUp += (_, e) => OnMouseInputEvent(PointToVector2(e.GetPosition(inputElement)), ConvertMouseButton(e.ChangedButton), InputEventType.Up);
            uiControlWpf.MouseWheel += (_, e) => OnMouseInputEvent(PointToVector2(e.GetPosition(inputElement)), MouseButton.Middle, InputEventType.Wheel, e.Delta);
            uiControlWpf.SizeChanged += OnWpfSizeChanged;

            ControlWidth = (float)uiControlWpf.ActualWidth;
            ControlHeight = (float)uiControlWpf.ActualHeight;
        }
        private void InitializeFromWindowsForms(GameContext uiContext)
        {
            uiControl = (Control) uiContext.Control;

            pointerClock.Restart();

            if (UseRawInput)
            {
                BindRawInputKeyboard(uiControl);
            }
            else
            {
                EnsureMapKeys();
                defaultWndProc = Win32Native.GetWindowLong(new HandleRef(this, uiControl.Handle), Win32Native.WindowLongType.WndProc);
                // This is needed to prevent garbage collection of the delegate.
                inputWndProc = WndProc;
                var inputWndProcPtr = Marshal.GetFunctionPointerForDelegate(inputWndProc);
                Win32Native.SetWindowLong(new HandleRef(this, uiControl.Handle), Win32Native.WindowLongType.WndProc, inputWndProcPtr);
            }
            uiControl.GotFocus += (_, e) => OnUiControlGotFocus();
            uiControl.LostFocus += (_, e) => OnUiControlLostFocus();
            uiControl.MouseMove += (_, e) => OnMouseMoveEvent(new Vector2(e.X, e.Y));
            uiControl.MouseDown += (_, e) => { uiControl.Focus(); OnMouseInputEvent(new Vector2(e.X, e.Y), ConvertMouseButton(e.Button), InputEventType.Down); };
            uiControl.MouseUp += (_, e) => OnMouseInputEvent(new Vector2(e.X, e.Y), ConvertMouseButton(e.Button), InputEventType.Up);
            uiControl.MouseWheel += (_, e) => OnMouseInputEvent(new Vector2(e.X, e.Y), MouseButton.Middle, InputEventType.Wheel, e.Delta);
            uiControl.MouseCaptureChanged += (_, e) => OnLostMouseCaptureWinForms();
            uiControl.SizeChanged += UiControlOnSizeChanged;

            ControlWidth = uiControl.ClientSize.Width;
            ControlHeight = uiControl.ClientSize.Height;
        }
Esempio n. 21
0
        /// <summary>
        /// Call this method to initialize the game, begin running the game loop, and start processing events for the game.
        /// </summary>
        /// <param name="gameContext">The window Context for this game.</param>
        /// <exception cref="System.InvalidOperationException">Cannot run this instance while it is already running</exception>
        public void Run(GameContext gameContext = null)
        {
            if (IsRunning)
            {
                throw new InvalidOperationException("Cannot run this instance while it is already running");
            }

            // Gets the graphics device manager
            graphicsDeviceManager = Services.GetService(typeof(IGraphicsDeviceManager)) as IGraphicsDeviceManager;
            if (graphicsDeviceManager == null)
            {
                throw new InvalidOperationException("No GraphicsDeviceManager found");
            }

            // Gets the GameWindow Context
            Context = gameContext ?? new GameContext();

            PrepareContext();

            try
            {
                // TODO temporary workaround as the engine doesn't support yet resize
                var graphicsDeviceManagerImpl = (GraphicsDeviceManager) graphicsDeviceManager;
                Context.RequestedWidth = graphicsDeviceManagerImpl.PreferredBackBufferWidth;
                Context.RequestedHeight = graphicsDeviceManagerImpl.PreferredBackBufferHeight;
                Context.RequestedBackBufferFormat = graphicsDeviceManagerImpl.PreferredBackBufferFormat;
                Context.RequestedDepthStencilFormat = graphicsDeviceManagerImpl.PreferredDepthStencilFormat;
                Context.RequestedGraphicsProfile = graphicsDeviceManagerImpl.PreferredGraphicsProfile;

                gamePlatform.Run(Context);

                if (gamePlatform.IsBlockingRun)
                {
                    // If the previous call was blocking, then we can call Endrun
                    EndRun();
                }
                else
                {
                    // EndRun will be executed on Game.Exit
                    isEndRunRequired = true;
                }
            }
            finally
            {
                if (!isEndRunRequired)
                {
                    IsRunning = false;
                }
            }
        }
Esempio n. 22
0
        public static void RunGameTest(GameBase game)
        {
            // Prepare finish callback
            var tcs = new TaskCompletionSource<bool>();
            EventHandler<EventArgs> gameFinishedCallback = (sender, e) =>
            {
                // Notify waiter that game has exited
                Logger.Info("Game finished.");
                tcs.TrySetResult(true);
            };

            EventHandler<GameUnhandledExceptionEventArgs> exceptionhandler = (sender, e) =>
            {
                Logger.Info("Game finished with exception ={0}.", e);
                tcs.TrySetException((Exception)e.ExceptionObject);
            };

            // Transmit data to activity
            // TODO: Avoid static with string intent + Dictionary?
            try
            {
                game.UnhandledException += exceptionhandler;

                Logger.Info(@"Starting activity");

#if SILICONSTUDIO_PLATFORM_IOS
                game.Exiting += gameFinishedCallback;

                UIApplication.SharedApplication.InvokeOnMainThread(() =>
                {
                    var window = UIApplication.SharedApplication.KeyWindow;
                    var rootNavigationController = (UINavigationController)window.RootViewController;

                    // create the paradox game view 
                    var bounds = UIScreen.MainScreen.Bounds;
                    var paradoxGameView = new Starter.ParadoxApplicationDelegate.iOSParadoxView((System.Drawing.RectangleF)bounds) { ContentScaleFactor = UIScreen.MainScreen.Scale };

                    // create the view controller used to display the paradox game
                    var paradoxGameController = new iOSGameTestController(game) { View = paradoxGameView };

                    // create the game context
                    var gameContext = new GameContext(window, paradoxGameView, paradoxGameController);

                    // push view
                    rootNavigationController.PushViewController(gameContext.GameViewController, false);

                    // launch the game
                    game.Run(gameContext);
                });
#elif SILICONSTUDIO_PLATFORM_ANDROID
                // Start activity
                AndroidGameTestActivity.Game = game;
                AndroidGameTestActivity.Destroyed += gameFinishedCallback;
                PlatformAndroid.Context.StartActivity(typeof (AndroidGameTestActivity));
#endif

                // Wait for completion of task
                // TODO: Should we put a timeout and issue a Game.Exit() in main thread if too long?
                tcs.Task.Wait();

                Logger.Info(@"Activity ended");
            }
            catch (AggregateException e)
            {
                // Unwrap aggregate exceptions
                if (e.InnerExceptions.Count == 1)
                    ExceptionDispatchInfo.Capture(e.InnerException).Throw();
            }
            finally
            {
#if SILICONSTUDIO_PLATFORM_IOS
                // iOS Cleanup
                UIApplication.SharedApplication.InvokeOnMainThread(() =>
                {
                    var window = UIApplication.SharedApplication.KeyWindow;
                    var rootNavigationController = (UINavigationController)window.RootViewController;

                    rootNavigationController.PopViewController(false);
                });
#elif SILICONSTUDIO_PLATFORM_ANDROID
                AndroidGameTestActivity.Game = null;
                AndroidGameTestActivity.Destroyed -= gameFinishedCallback;
#endif

                // Cleanup
                game.Exiting -= gameFinishedCallback;
                game.UnhandledException -= exceptionhandler;
            }
        }
Esempio n. 23
0
        internal override void Initialize(GameContext gameContext)
        {
            GameContext = gameContext;

            gameForm     = gameContext.GameView;
            nativeWindow = new WindowHandle(AppContextType.iOS, gameForm);

            gameForm.Load        += gameForm_Load;
            gameForm.Unload      += gameForm_Unload;
            gameForm.RenderFrame += gameForm_RenderFrame;

            // get the OpenGL ES version
            var contextAvailable = false;

            foreach (var version in OpenGLUtils.GetGLVersions(gameContext.RequestedGraphicsProfile))
            {
                var         contextRenderingApi = MajorVersionTOEAGLRenderingAPI(version);
                EAGLContext contextTest         = null;
                try
                {
                    contextTest = new EAGLContext(contextRenderingApi);

                    // delete extra context
                    if (contextTest != null)
                    {
                        contextTest.Dispose();
                    }

                    gameForm.ContextRenderingApi = contextRenderingApi;
                    contextAvailable             = true;
                }
                catch (Exception)
                {
                    // TODO: log message
                }
            }

            if (!contextAvailable)
            {
                throw new Exception("Graphics context could not be created.");
            }

            gameForm.LayerColorFormat = MonoTouch.OpenGLES.EAGLColorFormat.RGBA8;
            //gameForm.LayerRetainsBacking = false;

            // Setup the initial size of the window
            var width = gameContext.RequestedWidth;

            if (width == 0)
            {
                width = (int)(gameForm.Size.Width * gameForm.ContentScaleFactor);
            }

            var height = gameContext.RequestedHeight;

            if (height == 0)
            {
                height = (int)(gameForm.Size.Height * gameForm.ContentScaleFactor);
            }

            gameForm.Size = new Size(width, height);

            //gameForm.Resize += OnClientSizeChanged;
        }
Esempio n. 24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GameWindowRenderer" /> class.
 /// </summary>
 /// <param name="registry">The registry.</param>
 /// <param name="gameContext">The window context.</param>
 public GameWindowRenderer(IServiceRegistry registry, GameContext gameContext = null)
     : base(registry)
 {
     GameContext = gameContext ?? new GameContext();
 }
        /// <summary>
        /// Run the test.
        /// </summary>
        /// <param name="device">The device where to run the test.</param>
        /// <param name="gameContext">The game context.</param>
        public void RunTest(ConnectedDevice device, GameContext gameContext = null)
        {
            currentDevice = device;
            runTests = true;
            Console.WriteLine(@"Running test " + this.GetType().Name + @" on device " + device.Name + @" (" + device.Platform + @")");

            // TODO: should be executed after LoadContent for client - or at the first frame?
            RegisterTests();
            
            if (isServer)
            {
                Console.WriteLine(@"Running server" + (onBamboo ? @" on Bamboo" : @"" ));
                // Launch server
                SetUpServer();

                if (!serverUp)
                {
                    Assert.Fail("Unable to create a server.");
                    return;
                }

                // Reset some variables
                imageReceived = false;
                testPerformed = false;
                dataReceivedEvent = new ManualResetEvent(false);

                // Launch remote test
                Console.WriteLine(@"Waiting for a connection... ");
                //server.BeginAcceptTcpClient(GetClientResultCallback, server);
                RunTestOnDevice(device);
                
                // Wait until data is received or timeout
                dataReceivedEvent.WaitOne(Timeout);

                try
                {
                    Console.WriteLine(@"Stopping the server.");
                    serverUp = false;
                    StopServer();
                }
                catch (Exception)
                {
                    Console.WriteLine(@"Stopping the server threw an error.");
                }
                finally
                {
                    // Some tests
                    Assert.IsTrue(imageReceived, "The image was not received.");
                    Assert.IsTrue(testPerformed, "The tests were not correctly performed");
                }
            }
            else
            {
                Console.WriteLine(@"Running test client");
                // 1. Create client
                SetUpClient();

                // 2. Run game
                Run(gameContext);
            }
        }
Esempio n. 26
0
        public virtual GameWindow CreateWindow(GameContext gameContext)
        {
            gameContext = gameContext ?? new GameContext();

            var windows = GetSupportedGameWindows();

            foreach (var gameWindowToTest in windows)
            {
                if (gameWindowToTest.CanHandle(gameContext))
                {
                    gameWindowToTest.Services = Services;
                    gameWindowToTest.Initialize(gameContext);
                    return gameWindowToTest;
                }
            }

            throw new ArgumentException("Game Window context not supported on this platform");
        }
        internal override void Initialize(GameContext windowContext)
        {
            if (windowContext != null)
            {
                swapChainPanel = windowContext.Control as SwapChainPanel;
                if (swapChainPanel == null)
                {
                    throw new NotSupportedException(string.Format("Unsupported window context [{0}]. Only SwapChainPanel",  windowContext.Control.GetType().FullName));
                }
                windowHandle = new WindowHandle(AppContextType.WindowsRuntime, swapChainPanel);

#if SILICONSTUDIO_PLATFORM_WINDOWS_10
                var appView = ApplicationView.GetForCurrentView();
                if (appView != null && windowContext.RequestedWidth != 0 && windowContext.RequestedHeight != 0)
                    appView.TryResizeView(new Size(windowContext.RequestedWidth, windowContext.RequestedHeight));
#endif

                //clientBounds = new DrawingRectangle(0, 0, (int)swapChainPanel.ActualWidth, (int)swapChainPanel.ActualHeight);
                swapChainPanel.SizeChanged += swapChainPanel_SizeChanged;
                swapChainPanel.CompositionScaleChanged += swapChainPanel_CompositionScaleChanged;
            }
        }