freeso/TSOClient/FSOFacadeWorker/GraphicsDeviceServiceMock.cs
riperiperi b57ebbd141 Cleanup: Remove most unused usings and MPL per-file licenses
MPL per-file was used in older project files, but should apply to the whole project, so having it there was redundant.
2023-11-25 03:45:29 +00:00

53 lines
1.5 KiB
C#

using Microsoft.Xna.Framework.Graphics;
using System;
using System.Windows.Forms;
namespace FSOFacadeWorker
{
public class GraphicsDeviceServiceMock : IGraphicsDeviceService
{
GraphicsDevice _GraphicsDevice;
Form HiddenForm;
public GraphicsDeviceServiceMock()
{
HiddenForm = new Form()
{
Visible = true,
ShowInTaskbar = false
};
var Parameters = new PresentationParameters()
{
BackBufferWidth = 1280,
BackBufferHeight = 720,
DeviceWindowHandle = HiddenForm.Handle,
PresentationInterval = PresentInterval.Immediate,
IsFullScreen = false
};
_GraphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.Reach, Parameters);
_GraphicsDevice.Present();
}
public GraphicsDevice GraphicsDevice
{
get { return _GraphicsDevice; }
}
public event EventHandler<EventArgs> DeviceCreated;
public event EventHandler<EventArgs> DeviceDisposing;
public event EventHandler<EventArgs> DeviceReset;
public event EventHandler<EventArgs> DeviceResetting;
public void Release()
{
_GraphicsDevice.Dispose();
_GraphicsDevice = null;
HiddenForm.Close();
HiddenForm.Dispose();
HiddenForm = null;
}
}
}