當前位置: 首頁>>代碼示例>>C#>>正文


C# Toolkit.GameContext類代碼示例

本文整理匯總了C#中SharpDX.Toolkit.GameContext的典型用法代碼示例。如果您正苦於以下問題:C# GameContext類的具體用法?C# GameContext怎麽用?C# GameContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


GameContext類屬於SharpDX.Toolkit命名空間,在下文中一共展示了GameContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CreateWindow

        public virtual GameWindow CreateWindow(GameContext gameContext)
        {
            gameContext = gameContext ?? new GameContext();

            var windows = GetSupportedGameWindows();

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

            throw new ArgumentException("Game Window context not supported on this platform");
        }
開發者ID:rbwhitaker,項目名稱:SharpDX,代碼行數:17,代碼來源:GamePlatform.cs

示例2: Initialize

        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;
            }

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

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

            gameForm = Control as RenderForm;
            if (gameForm != null)
            {
                gameForm.AppActivated += OnActivated;
                gameForm.AppDeactivated += OnDeactivated;
                gameForm.UserResized += OnClientSizeChanged;
            }
            else
            {
                Control.Resize += OnClientSizeChanged;
            }
        }
開發者ID:Ziriax,項目名稱:SharpDX,代碼行數:36,代碼來源:GameWindowDesktop.cs

示例3: CanHandle

 internal override bool CanHandle(GameContext gameContext)
 {
     return gameContext.ContextType == GameContextType.WindowsPhoneXaml;
 }
開發者ID:QuantumDeveloper,項目名稱:SharpDX,代碼行數:4,代碼來源:GameWindowPhoneXaml.cs

示例4: Initialize

 internal override void Initialize(GameContext gameContext)
 {
     drawingSurface = (DrawingSurface)gameContext.Control;
 }
開發者ID:GraphineCharles,項目名稱:SharpDX,代碼行數:4,代碼來源:GameWindowWindowsPhoneXaml.cs

示例5: Run

        public void Run(GameContext gameContext)
        {
            gameWindow = CreateWindow(gameContext);

            // Register on Activated 
            gameWindow.Activated += OnActivated;
            gameWindow.Deactivated += OnDeactivated;
            gameWindow.InitCallback = game.InitializeBeforeRun;
            gameWindow.RunCallback = game.Tick;
            gameWindow.ExitCallback = () => OnExiting(this, EventArgs.Empty);

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

            gameWindow.Run();
        }
開發者ID:BrianLunt,項目名稱:SharpDX,代碼行數:19,代碼來源:GamePlatform.cs

示例6: Initialize

        /// <inheritdoc />
        internal override void Initialize(GameContext gameContext)
        {
            GameContext = gameContext;

            if (gameContext.ContextType == GameContextType.Desktop)
            {
                Control = (Control)gameContext.Control;
                InitializeFromWinForm();
            }
            else if (gameContext.ContextType == GameContextType.DesktopHwndWpf)
            {
                InitializeFromWpfControl(gameContext.Control);
            }
        }
開發者ID:Keldrim,項目名稱:SharpDX,代碼行數:15,代碼來源:GameWindowDesktop.cs

示例7: CanHandle

 internal override bool CanHandle(GameContext windowContext)
 {
     return windowContext.ContextType == GameContextType.WinRTBackgroundXaml;
 }
開發者ID:GrafSeismo,項目名稱:SharpDX,代碼行數:4,代碼來源:GameWindowWinRTXaml.cs

示例8: GameWindowRenderer

 /// <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();
 }
開發者ID:QuantumDeveloper,項目名稱:SharpDX,代碼行數:10,代碼來源:GameWindowRenderer.cs

示例9: Run

        public void Run(GameContext gameContext)
        {
            gameWindow = CreateWindow(gameContext);

            // set the mouse visibility in case if it was set in the game constructor:
            gameWindow.IsMouseVisible = game.IsMouseVisible;

            // Register on Activated 
            gameWindow.Activated += OnActivated;
            gameWindow.Deactivated += OnDeactivated;
            gameWindow.InitCallback = game.InitializeBeforeRun;
            gameWindow.RunCallback = game.Tick;
            gameWindow.ExitCallback = () => OnExiting(this, EventArgs.Empty);

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

            gameWindow.Run();
        }
開發者ID:GrafSeismo,項目名稱:SharpDX,代碼行數:22,代碼來源:GamePlatform.cs

示例10: Switch

        internal override void Switch(GameContext context)
        {
            surfaceControl.SizeChanged -= SurfaceControlSizeChanged;

            BindSurfaceControl(context);
        }
開發者ID:numo16,項目名稱:SharpDX,代碼行數:6,代碼來源:GameWindowWinRTXaml.cs

示例11: BindSurfaceControl

        private void BindSurfaceControl(GameContext windowContext)
        {
            surfaceControl = windowContext.Control as FrameworkElement;
            if (surfaceControl == null)
                throw new ArgumentException("A FrameworkElement expected.");

            surfaceControl.SizeChanged += SurfaceControlSizeChanged;
        }
開發者ID:numo16,項目名稱:SharpDX,代碼行數:8,代碼來源:GameWindowWinRTXaml.cs

示例12: Initialize

        internal override void Initialize(GameContext gameContext)
        {
            if (gameContext == null) throw new ArgumentNullException("gameContext");

            element = gameContext.Control as SharpDXElement;
            if (element == null) throw new ArgumentException("Only SharpDXElement is supported at this time", "gameContext");

            var width = gameContext.RequestedWidth;
            if (width <= 0)
                width = GraphicsDeviceManager.DefaultBackBufferWidth;

            var height = gameContext.RequestedHeight;
            if (height <= 0)
                height = GraphicsDeviceManager.DefaultBackBufferHeight;

            element.TrySetSize(width, height);

            element.ResizeCompleted += OnClientSizeChanged;
            element.MouseEnter += OnMouseEnter;
            element.MouseLeave += OnMouseLeave;
        }
開發者ID:GrafSeismo,項目名稱:SharpDX,代碼行數:21,代碼來源:GameWindowDesktopWpf.cs

示例13: Switch

        internal override void Switch(GameContext context)
        {
            isInitialized = false;

            drawingSurfaceBackgroundGrid.Loaded -= DrawingSurfaceBackgroundGridOnLoaded;
            drawingSurfaceBackgroundGrid.Unloaded -= drawingSurfaceBackgroundGrid_Unloaded;
            drawingSurfaceBackgroundGrid.SetBackgroundContentProvider(null);

            drawingSurfaceBackgroundGrid = (DrawingSurfaceBackgroundGrid)context.Control;

            BindDrawingSurfaceBackgroundGridEvents();
            // TODO: check if this can cause issues as event "Loaded" never gets called
            drawingSurfaceBackgroundGrid.SetBackgroundContentProvider(this);

            currentDevice = null;
            currentDeviceContext = null;
        }
開發者ID:numo16,項目名稱:SharpDX,代碼行數:17,代碼來源:GameWindowPhoneBackgroundXaml.cs

示例14: CanHandle

        internal override bool CanHandle(GameContext gameContext)
        {
            if (gameContext == null) throw new ArgumentNullException("gameContext");

            return gameContext.ContextType == GameContextType.DesktopWpf;
        }
開發者ID:GrafSeismo,項目名稱:SharpDX,代碼行數:6,代碼來源:GameWindowDesktopWpf.cs

示例15: Switch

 internal override void Switch(GameContext context)
 {
     // Nothing to switch here, GameContext is not used in this implementation.
 }
開發者ID:chantsunman,項目名稱:Toolkit,代碼行數:4,代碼來源:GameWindowWinRT.cs


注:本文中的SharpDX.Toolkit.GameContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。