예제 #1
0
        /// <summary>
        /// Initialises common methods
        /// </summary>
        protected void Initialise(bool fullscreen)
        {
            //Sets keyboard events
            Events.KeyboardDown += new EventHandler<KeyboardEventArgs>(this.KeyDown);
            Events.KeyboardUp += new EventHandler<KeyboardEventArgs>(Events_KeyboardUp);

            //Sets the ticker to update OpenGL context
            Events.Tick += new EventHandler<TickEventArgs>(this.Tick);
            //Registers Quit event
            Events.Quit += new EventHandler<QuitEventArgs>(this.Quit);

            //Set the Frames per Second
            Events.Fps = 500;

            //Enable Key Repeating
            Keyboard.EnableKeyRepeat(20, 1);

            //Sets Window icon and Title
            this.WindowAttributes();

            Rectangle lastScreenBounds;

            //if (Screen.AllScreens.Length > 1)
            if (Screen.AllScreens[0].Primary == false && fullscreen==true)
            {
                //lastScreenBounds = Screen.AllScreens[Screen.AllScreens.Length - 1].Bounds;
                lastScreenBounds = Screen.AllScreens[0].Bounds;
            }
            else
            {
                try
                {
                    lastScreenBounds = Screen.AllScreens[1].Bounds;
                    fullscreen = false;
                }
                catch (IndexOutOfRangeException ex)
                {
                    lastScreenBounds = Screen.AllScreens[(Screen.AllScreens.Length - 1)].Bounds;
                    fullscreen = false;
                    System.Diagnostics.Debug.WriteLine("Only one screen appears to be connected. Exception Message: " + ex.Message);
                }
            }

            //if (lastScreenBounds.X == 0 && Screen.AllScreens.Length > 1)
            //{
            //    lastScreenBounds = Screen.AllScreens[Screen.AllScreens.Length - 2].Bounds;
            //}

            if (fullscreen)
            {
                //Maximise the screen to the second monitor
                m_screen = Video.SetVideoMode(lastScreenBounds.Width, lastScreenBounds.Height, m_bpp, true, true, false, true, false);
                Win32.SetWindowPos(Video.WindowHandle, Win32.HWND_NOTOPMOST, lastScreenBounds.X, lastScreenBounds.Y, lastScreenBounds.Width, lastScreenBounds.Height, Win32.SWP_SHOWWINDOW);
            }
            else
            {
                IntPtr visualiserWindowHandle = Win32.FindWindow(null, "StromoLight Visualiser");

                int x = (System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width / 2) + 4;
                int y = 5;
                int width = (System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width / 2) - 16;
                int height = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height - 38;
                Win32.SetWindowPos(visualiserWindowHandle,
                        Win32.HWND_TOP,
                        x,
                        y,
                        width,
                        height,
                        Win32.SWP_SHOWWINDOW);

                m_screen = Video.SetVideoMode(width, height, m_bpp, false, true, false, true, true);
                
            }
            m_fullScreen = fullscreen;

            Transformation transform = new Transformation(90);

            //force toggle methid
            //m_fullScreen = true;
            //ToggleFullscreen();
        }
예제 #2
0
파일: Surface.cs 프로젝트: ywjno/mynes-code
 /// <summary>
 /// Uses a Transformation object to perform rotation, zooming/scaling
 /// </summary>
 /// <param name="transformation">Transformation object</param>
 public Surface CreateTransformedSurface(Transformation transformation)
 {
     //this method and has duplicate logic with CreateRotatedZoomedSurface.
     if (this.disposed)
     {
         throw (new ObjectDisposedException(this.ToString()));
     }
     if (transformation == null)
     {
         throw new ArgumentNullException("transformation");
     }
     int antiAliasParameter = (transformation.AntiAlias) ? (SdlGfx.SMOOTHING_ON) : (SdlGfx.SMOOTHING_OFF);
     Surface surface =
         new Surface(
             SdlGfx.rotozoomSurfaceXY(
                 this.Handle,
                 transformation.DegreesOfRotation,
                 transformation.ScaleX,
                 transformation.ScaleY,
                 antiAliasParameter));
     CloneFields(this, surface);
     return surface;
 }