/// <summary> /// 各パラメーターをデフォルトにします /// </summary> public void SetDefault() { Hidden = childChanged = lastOnMouse = mouseLeftDown = mouseRightDown = mouseMiddleDown = false; Scale = Vector2.One; lastMousePos = Position = RotationCenter = ScaleCenter = Vector2.Zero; Alpha = 1; Rotation = 0; PreScreenFilters.Clear(); PostScreenFilters.Clear(); ColorFilters.Clear(); RenderMasks.Clear(); }
// --------------------------------------------------------- protected override void Initialize() { SetupMatrices(); SetupRenderTargets(); _PostScreenFilters = new PostScreenFilters( _Width, _Height, GraphicsDevice, Content); InitializeModels(); base.Initialize(); basicEffect = new BasicEffect(GraphicsDevice) { TextureEnabled = true, VertexColorEnabled = true, }; controls = new Controls(this); controls.Show(); }
void toggleFullscreen() { float AspectRatio; bToggleFullscreen = false; if (GraphicsDevice.Viewport.Width < System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width) { _Width = Screenwidth; _Height = Screenheight; AspectRatio = (float)_Width / (float)_Height; Window.IsBorderless = true; windowPos = Window.Position; Window.Position = new Point(0, 0); _WorldProjection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45), AspectRatio, 0.01f, 1000f); graphics.PreferredBackBufferWidth = _Width; graphics.PreferredBackBufferHeight = _Height; graphics.ApplyChanges(); if (bDesktopBackground) { // * Following code is taken from "Draw Behind Desktop Icons in Windows 8" // * http://www.codeproject.com/Articles/856020/Draw-behind-Desktop-Icons-in-Windows // * // * by Gerald Degeneve (http://www.codeproject.com/script/Membership/View.aspx?mid=8529137) // * // * Thanks a lot Gerald! Really awsome cool ;) // * // Fetch the Progman window IntPtr progman = W32.FindWindow("Progman", null); IntPtr result = IntPtr.Zero; // Send 0x052C to Progman. This message directs Progman to spawn a // WorkerW behind the desktop icons. If it is already there, nothing // happens. W32.SendMessageTimeout(progman, 0x052C, new IntPtr(0), IntPtr.Zero, W32.SendMessageTimeoutFlags.SMTO_NORMAL, 1000, out result); IntPtr workerw = IntPtr.Zero; // We enumerate all Windows, until we find one, that has the SHELLDLL_DefView // as a child. // If we found that window, we take its next sibling and assign it to workerw. W32.EnumWindows(new W32.EnumWindowsProc((tophandle, topparamhandle) => { IntPtr p = W32.FindWindowEx(tophandle, IntPtr.Zero, "SHELLDLL_DefView", IntPtr.Zero); if (p != IntPtr.Zero) { // Gets the WorkerW Window after the current one. workerw = W32.FindWindowEx(IntPtr.Zero, tophandle, "WorkerW", IntPtr.Zero); } return(true); }), IntPtr.Zero); // We now have the handle of the WorkerW behind the desktop icons. // We can use it to create a directx device to render 3d output to it, // we can use the System.Drawing classes to directly draw onto it, // and of course we can set it as the parent of a windows form. // // There is only one restriction. The window behind the desktop icons does // NOT receive any user input. So if you want to capture mouse movement, // it has to be done the LowLevel way (WH_MOUSE_LL, WH_KEYBOARD_LL). // ************************************************************************************************ W32.SetParent(Window.Handle, workerw); } } else { _Width = _DefaultWidth; _Height = _DefaultHeight; AspectRatio = (float)_Width / (float)_Height; Window.IsBorderless = false; _WorldProjection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45), AspectRatio, 0.01f, 1000f); graphics.PreferredBackBufferWidth = _Width; graphics.PreferredBackBufferHeight = _Height; graphics.ApplyChanges(); Window.Position = windowPos; if (bDesktopBackground) { W32.SetParent(Window.Handle, IntPtr.Zero); //restore wallpaper W32.SystemParametersInfo(W32.SPI_SETDESKWALLPAPER, 0, null, W32.SPIF_UPDATEINIFILE); bDesktopBackground = false; } } //Apply new screen size & aspect ratio to the render targets SetupRenderTargets(); _PostScreenFilters = new PostScreenFilters( _Width, _Height, GraphicsDevice, Content); }