本文整理汇总了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");
}
示例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;
}
}
示例3: CanHandle
internal override bool CanHandle(GameContext gameContext)
{
return gameContext.ContextType == GameContextType.WindowsPhoneXaml;
}
示例4: Initialize
internal override void Initialize(GameContext gameContext)
{
drawingSurface = (DrawingSurface)gameContext.Control;
}
示例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();
}
示例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);
}
}
示例7: CanHandle
internal override bool CanHandle(GameContext windowContext)
{
return windowContext.ContextType == GameContextType.WinRTBackgroundXaml;
}
示例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();
}
示例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();
}
示例10: Switch
internal override void Switch(GameContext context)
{
surfaceControl.SizeChanged -= SurfaceControlSizeChanged;
BindSurfaceControl(context);
}
示例11: BindSurfaceControl
private void BindSurfaceControl(GameContext windowContext)
{
surfaceControl = windowContext.Control as FrameworkElement;
if (surfaceControl == null)
throw new ArgumentException("A FrameworkElement expected.");
surfaceControl.SizeChanged += SurfaceControlSizeChanged;
}
示例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;
}
示例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;
}
示例14: CanHandle
internal override bool CanHandle(GameContext gameContext)
{
if (gameContext == null) throw new ArgumentNullException("gameContext");
return gameContext.ContextType == GameContextType.DesktopWpf;
}
示例15: Switch
internal override void Switch(GameContext context)
{
// Nothing to switch here, GameContext is not used in this implementation.
}