• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Toolkit.GameContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中SharpDX.Toolkit.GameContext的典型用法代码示例。如果您正苦于以下问题:C# GameContext类的具体用法?C# GameContext怎么用?C# GameContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GameContext类属于SharpDX.Toolkit命名空间,在下文中一共展示了GameContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: Initialize

 internal override void Initialize(GameContext windowContext)
 {
 }
开发者ID:chantsunman,项目名称:Toolkit,代码行数:3,代码来源:GameWindowWinRT.cs


示例17: Initialize

 internal override void Initialize(GameContext gameContext)
 {
     drawingSurface = (DrawingSurface)gameContext.Control;
     graphicsDeviceService = (IGraphicsDeviceService)Services.GetService(typeof(IGraphicsDeviceService));
     graphicsDeviceManager = (IGraphicsDeviceManager)Services.GetService(typeof(IGraphicsDeviceManager));
 }
开发者ID:QuantumDeveloper,项目名称:SharpDX,代码行数:6,代码来源:GameWindowPhoneXaml.cs


示例18: Initialize

 internal override void Initialize(GameContext windowContext)
 {
     if (windowContext != null)
     {
         BindSurfaceControl(windowContext);
     }
 }
开发者ID:Keldrim,项目名称:SharpDX,代码行数:7,代码来源:GameWindowWinRTXaml.cs


示例19: Switch

        internal override void Switch(GameContext context)
        {
            drawingSurface.Loaded -= DrawingSurfaceOnLoaded;
            drawingSurface.Unloaded -= DrawingSurfaceUnloaded;
            drawingSurface.SetContentProvider(null);

            drawingSurface = (DrawingSurface)context.Control;
            isInitialized = false;
            synchronizedTexture.Dispose();
            synchronizedTexture = null;

            drawingSurface.Loaded += DrawingSurfaceOnLoaded;
            drawingSurface.Unloaded += DrawingSurfaceUnloaded;

            drawingSurface.SetContentProvider(this);
        }
开发者ID:QuantumDeveloper,项目名称:SharpDX,代码行数:16,代码来源:GameWindowPhoneXaml.cs


示例20: BindSurfaceControl

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

            surfaceControl.SizeChanged += SurfaceControlSizeChanged;

            var swapChainPanel = surfaceControl as SwapChainPanel;
            if (swapChainPanel != null)
                swapChainPanel.CompositionScaleChanged += SwapChainPanelCompositionScaleChanged;
        }
开发者ID:Keldrim,项目名称:SharpDX,代码行数:12,代码来源:GameWindowWinRTXaml.cs



注:本文中的SharpDX.Toolkit.GameContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Toolkit.GameTime类代码示例发布时间:2022-05-26
下一篇:
C# DirectWrite.TextFormat类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap