Esempio n. 1
0
        /***************************************************************************/
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="ThisWindowVariable"></param>
        /// <returns>true if the window was newly created and will need to be explicly shown.</returns>
        protected bool CreateSingletonModelessWindow <T>(BoxedScalar <T> ThisWindowVariable) where T : CustomBaseWindow, new()
        {
            if (ThisWindowVariable.Value != null)
            {
                ThisWindowVariable.Value.Activate();

                /// Restore a minimized window.
                if (ThisWindowVariable.Value.WindowState == WindowState.Minimized)
                {
                    ThisWindowVariable.Value.WindowState = WindowState.Normal;
                }

                return(false);
            }
            else
            {
                ThisWindowVariable.Value = new T();

                /// This event does nothing more than set the variable to null when the window is closed.
                ThisWindowVariable.Value.Closed += (new CloseSingletonModelessWindowEventDesc <T>(ThisWindowVariable)).OnClose;

                ThisWindowVariable.Value.Owner = this;
                ThisWindowVariable.Value.Scale = App.s_fInterfaceScaleFactor;
                return(true);
            }
        }
Esempio n. 2
0
        /***************************************************************************/
        /// <summary>
        /// This function throws an exception if the window in question didn't close.
        /// It assumes that the window was created with CreateSingletonModelessWindow<>().
        /// </summary>
        protected void TryCloseSingletonModelessWindow <T>(BoxedScalar <T> ThisWindowVariable) where T : CustomBaseWindow
        {
            if (ThisWindowVariable.Value != null)
            {
                ThisWindowVariable.Value.Activate();
                ThisWindowVariable.Value.Close();

                /// If the window object reference still exists, it means the OnClose event was never called, meaning it never closed.
                /// And that means the window must have refused it.
                if (ThisWindowVariable.Value != null)
                {
                    throw new Exception("Window refused to close, either on its own or because of user input.");
                }
            }

            return;
        }
Esempio n. 3
0
 public CloseSingletonModelessWindowEventDesc(BoxedScalar <T> ThisWindow)
 {
     m_wndWindow = ThisWindow;
     return;
 }