/// <summary> /// Load and Initialize Game Components /// </summary> public override void LoadContent() { //Adjust DWM frame settings int[] margins = new int[] { 0, 0, ScreenManager.maxWidth, ScreenManager.maxHeight }; User32.DwmExtendFrameIntoClientArea(ScreenManager.Game.Window.Handle, ref margins); DepthStencilState depthState = new DepthStencilState(); depthState.DepthBufferEnable = false; depthState.DepthBufferWriteEnable = false; ScreenManager.GraphicsDevice.DepthStencilState = depthState; //Hook the interceptKeys module InterceptKeys.Hook(); bciControl = new WowControl(ScreenManager.Game); ScreenManager.Game.Components.Add(bciControl); ssvepDX = new SSVEP_DirectX_Advanced_V2(ScreenManager.Game); ssvepDX.Initialize(ScreenManager.form, ScreenManager.SpriteBatch); ScreenManager.Game.Components.Add(ssvepDX); }
//Initialize protected override void Initialize() { System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.RealTime; //Set the windows forms, and directX graphics buffer to match the screen of the host computer int maxHeight = 0; int maxWidth = 0; // vars to choose the max width and height GraphicsAdapter g = graphics.GraphicsDevice.Adapter; foreach (DisplayMode dm in g.SupportedDisplayModes) { if (maxHeight < dm.Height) { maxHeight = dm.Height; } if (maxWidth < dm.Width) { maxWidth = dm.Width; } } graphics.PreferredBackBufferHeight = maxHeight; graphics.PreferredBackBufferWidth = maxWidth; //Configure DirectX graphics device graphics.GraphicsDevice.DepthStencilState = DepthStencilState.None; graphics.PreferMultiSampling = false; //Set to true to have smooth texture edges GraphicsDevice.PresentationParameters.PresentationInterval = PresentInterval.One; graphics.ApplyChanges(); //Merge directX drawing buffer with GDI+ drawing surface int[] margins = new int[] { 0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight }; User32.DwmExtendFrameIntoClientArea(Window.Handle, ref margins); //xna game form form = System.Windows.Forms.Control.FromHandle(Window.Handle).FindForm(); form.Visible = true; form.AllowTransparency = true; //form.BackColor = System.Drawing.Color.Transparent; form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; form.TransparencyKey = form.BackColor; form.TopMost = true; form.DesktopLocation = new System.Drawing.Point(0, 0); form.ClientSize = new System.Drawing.Size(GraphicsDevice.DisplayMode.Width, GraphicsDevice.DisplayMode.Height); //Create a new directX spritebatch spriteBatch = new SpriteBatch(GraphicsDevice); //Initialize SSVEP (Using DirectX) SSVEP_DirectX_Advanced_V2 ssvepDX = new SSVEP_DirectX_Advanced_V2(this); ssvepDX.Initialize(form, spriteBatch); Components.Add(ssvepDX); switch (selectedApp) { case 0: var appControl = new BCI_Logic.BCI2000_Control.AnyApp.AdvancedControl(this); Components.Add(appControl); break; case 1: var appControl1 = new BCI_Logic.BCI2000_Control.AnyApp.BasicControl(this); Components.Add(appControl1); break; case 2: var appControl2 = new WowControl(this, "World Of Warcraft"); Components.Add(appControl2); break; case 3: var appControl3 = new SpecificAppControl(this, "Google Earth"); Components.Add(appControl3); break; case 4: var appControl4 = new CursorControl(this); Components.Add(appControl4); break; case 5: var appControl5 = new BCI_Logic.BCI2000_Control.AnyApp.AdvancedControl(this); Components.Add(appControl5); break; } //Cursor practice // InitCursor(); //mousePos.X=GraphicsDevice.Viewport.Width / 2; //mousePos.Y=GraphicsDevice.Viewport.Height / 2; //Mouse.SetPosition(mousePos.X,mousePos.Y); base.Initialize(); }