示例#1
0
        /// <summary>
        /// Gets the controller screen in single and multiple screen environments.
        /// </summary>
        /// <returns>The <see cref="Screen"/> which is not
        /// the presentation screen in dual monitor setups,
        /// otherwise, otherwise primary screen.</returns>
        public static Screen GetControllerScreen()
        {
            Monitor presentationMonitor;

            try
            {
                presentationMonitor = (Monitor)Enum.Parse(typeof(Monitor), Properties.Settings.Default.PresentationScreenMonitor);
            }
            catch (ArgumentException)
            {
                // error on parsing ... take primary
                presentationMonitor = Monitor.Primary;
                Properties.Settings.Default.PresentationScreenMonitor = "Primary";
            }

            // Return the controller monitor screen
            if (presentationMonitor == Monitor.Secondary || !SecondaryScreen.SystemHasSecondaryScreen())
            {
                return(Screen.PrimaryScreen);
            }
            else
            {
                return(SecondaryScreen.GetSecondaryScreen());
            }
        }
示例#2
0
        ///////////////////////////////////////////////////////////////////////////////
        // Defining Constants                                                        //
        ///////////////////////////////////////////////////////////////////////////////
        #region CONSTANTS
        #endregion //CONSTANTS

        ///////////////////////////////////////////////////////////////////////////////
        // Defining Variables, Enumerations, Events                                  //
        ///////////////////////////////////////////////////////////////////////////////
        #region FIELDS
        #endregion //FIELDS

        ///////////////////////////////////////////////////////////////////////////////
        // Construction and Initializing methods                                     //
        ///////////////////////////////////////////////////////////////////////////////
        #region CONSTRUCTION
        #endregion //CONSTRUCTION

        ///////////////////////////////////////////////////////////////////////////////
        // Defining Properties                                                       //
        ///////////////////////////////////////////////////////////////////////////////
        #region PROPERTIES
        #endregion //PROPERTIES

        ///////////////////////////////////////////////////////////////////////////////
        // Public methods                                                            //
        ///////////////////////////////////////////////////////////////////////////////
        #region PUBLICMETHODS

        /// <summary>
        /// Places given form at optional full size on the presentation screen.
        /// You can change the Presentation screen in Ogama Options
        /// or recording module.
        /// </summary>
        /// <param name="form">Windows form to put on presentation screen</param>
        /// <param name="fullSize">True, if form should be resized to fullscreen</param>
        /// <returns>True, if function succeeded.</returns>
        public static bool PutFormOnPresentationScreen(Form form, bool fullSize)
        {
            Monitor presentationMonitor;

            try
            {
                presentationMonitor = (Monitor)Enum.Parse(typeof(Monitor), Properties.Settings.Default.PresentationScreenMonitor);
            }
            catch (ArgumentException)
            {
                return(false);
            }

            // Important !
            form.StartPosition = FormStartPosition.Manual;

            // Get the monitor screen
            Screen screen;

            if (presentationMonitor == Monitor.Primary)
            {
                screen = Screen.PrimaryScreen;
            }
            else
            {
                if (presentationMonitor == Monitor.Secondary)
                {
                    if (SecondaryScreen.SystemHasSecondaryScreen())
                    {
                        screen = SecondaryScreen.GetSecondaryScreen();
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }

            // set the location to the top left of the presentation screen
            form.Location = screen.Bounds.Location;
            if (fullSize)
            {
                // set it fullscreen
                form.Size = new Size(screen.Bounds.Width, screen.Bounds.Height);
            }

            return(true);
        }