/// <summary>
            /// Converts a string into a Font object.
            /// </summary>
            /// <param name="font">A number that represents the font.</param>
            /// <returns>Font object.</returns>
            public static Font ToFont(string font)
            {
                int fontType = System.Convert.ToInt32(font);

                return(FontManager.GetFont((FontManager.FontType)fontType));
            }
        /// <summary>
        /// Shows a MessageBox on screen.
        /// </summary>
        /// <param name="message">Message</param>
        /// <param name="title">Title</param>
        /// <param name="buttons">MessageBoxButtons constant.</param>
        /// <returns></returns>
        public ModalResult Show(string message, string title, ModalButtons buttons)
        {
            _window     = Glide.MainWindow;
            _result     = ModalResult.None;
            _resetEvent = new ManualResetEvent(false);

            while (_msgBox.NumChildren > 0)
            {
                _msgBox.RemoveChildAt(0);
            }

            Update(message, title);

            Button abortBtn, okBtn, cancelBtn, retryBtn, ignoreBtn, yesBtn, noBtn;
            int    startX;
            int    buttonY = _msgBox.Height - 32 - 10;

            switch (buttons)
            {
            case ModalButtons.Ok:
                okBtn           = new Button("okBtn", 255, (_msgBox.Width - 50) / 2, buttonY, 50, 32);
                okBtn.Text      = "Ok";
                okBtn.Font      = FontManager.GetFont(FontManager.FontType.droid_reg11);
                okBtn.TapEvent += new OnTap(okBtn_TapEvent);
                _msgBox.AddChild(okBtn);
                break;

            case ModalButtons.OkCancel:
                startX = (_msgBox.Width - (50 + 5 + 70)) / 2;

                okBtn           = new Button("okBtn", 255, startX, buttonY, 50, 32);
                okBtn.Text      = "Ok";
                okBtn.Font      = FontManager.GetFont(FontManager.FontType.droid_reg11);
                okBtn.TapEvent += new OnTap(okBtn_TapEvent);
                _msgBox.AddChild(okBtn);

                cancelBtn           = new Button("cancelBtn", 255, okBtn.X + okBtn.Width + 5, buttonY, 70, 32);
                cancelBtn.Text      = "Cancel";
                cancelBtn.Font      = FontManager.GetFont(FontManager.FontType.droid_reg11);
                cancelBtn.TapEvent += new OnTap(cancelBtn_TapEvent);
                _msgBox.AddChild(cancelBtn);
                break;

            case ModalButtons.RetryCancel:
                startX = (_msgBox.Width - (60 + 5 + 70)) / 2;

                retryBtn           = new Button("retryBtn", 255, startX, buttonY, 60, 32);
                retryBtn.Text      = "Retry";
                retryBtn.Font      = FontManager.GetFont(FontManager.FontType.droid_reg11);
                retryBtn.TapEvent += new OnTap(retryBtn_TapEvent);
                _msgBox.AddChild(retryBtn);

                cancelBtn           = new Button("cancelBtn", 255, retryBtn.X + retryBtn.Width + 5, buttonY, 70, 32);
                cancelBtn.Text      = "Cancel";
                cancelBtn.Font      = FontManager.GetFont(FontManager.FontType.droid_reg11);
                cancelBtn.TapEvent += new OnTap(cancelBtn_TapEvent);
                _msgBox.AddChild(cancelBtn);
                break;

            case ModalButtons.AbortRetryIgnore:
                startX = (_msgBox.Width - (60 + 5 + 60 + 5 + 70)) / 2;

                abortBtn           = new Button("abortBtn", 255, startX, buttonY, 60, 32);
                abortBtn.Text      = "Abort";
                abortBtn.Font      = FontManager.GetFont(FontManager.FontType.droid_reg11);
                abortBtn.TapEvent += new OnTap(abortBtn_TapEvent);
                _msgBox.AddChild(abortBtn);

                retryBtn           = new Button("retryBtn", 255, abortBtn.X + abortBtn.Width + 5, buttonY, 60, 32);
                retryBtn.Text      = "Retry";
                retryBtn.Font      = FontManager.GetFont(FontManager.FontType.droid_reg11);
                retryBtn.TapEvent += new OnTap(retryBtn_TapEvent);
                _msgBox.AddChild(retryBtn);

                ignoreBtn           = new Button("ignoreBtn", 255, retryBtn.X + retryBtn.Width + 5, buttonY, 70, 32);
                ignoreBtn.Text      = "Ignore";
                ignoreBtn.Font      = FontManager.GetFont(FontManager.FontType.droid_reg11);
                ignoreBtn.TapEvent += new OnTap(ignoreBtn_TapEvent);
                _msgBox.AddChild(ignoreBtn);
                break;

            case ModalButtons.YesNo:
                startX = (_msgBox.Width - (55 + 5 + 60)) / 2;

                yesBtn           = new Button("yesBtn", 255, startX, buttonY, 55, 32);
                yesBtn.Text      = "Yes";
                yesBtn.Font      = FontManager.GetFont(FontManager.FontType.droid_reg11);
                yesBtn.TapEvent += new OnTap(yesBtn_TapEvent);
                _msgBox.AddChild(yesBtn);

                noBtn           = new Button("noBtn", 255, yesBtn.X + yesBtn.Width + 5, buttonY, 50, 32);
                noBtn.Text      = "No";
                noBtn.Font      = FontManager.GetFont(FontManager.FontType.droid_reg11);
                noBtn.TapEvent += new OnTap(noBtn_TapEvent);
                _msgBox.AddChild(noBtn);
                break;

            case ModalButtons.YesNoCancel:
                startX = (_msgBox.Width - (55 + 5 + 50 + 5 + 70)) / 2;

                yesBtn           = new Button("yesBtn", 255, startX, buttonY, 55, 32);
                yesBtn.Text      = "Yes";
                yesBtn.Font      = FontManager.GetFont(FontManager.FontType.droid_reg11);
                yesBtn.TapEvent += new OnTap(yesBtn_TapEvent);
                _msgBox.AddChild(yesBtn);

                noBtn           = new Button("noBtn", 255, yesBtn.X + yesBtn.Width + 5, buttonY, 50, 32);
                noBtn.Text      = "No";
                noBtn.Font      = FontManager.GetFont(FontManager.FontType.droid_reg11);
                noBtn.TapEvent += new OnTap(noBtn_TapEvent);
                _msgBox.AddChild(noBtn);

                cancelBtn           = new Button("cancelBtn", 255, noBtn.X + noBtn.Width + 5, buttonY, 70, 32);
                cancelBtn.Text      = "Cancel";
                cancelBtn.Font      = FontManager.GetFont(FontManager.FontType.droid_reg11);
                cancelBtn.TapEvent += new OnTap(cancelBtn_TapEvent);
                _msgBox.AddChild(cancelBtn);
                break;
            }

            _forceClose           = false;
            _touchThread          = new Thread(TouchThread);
            _touchThread.Priority = ThreadPriority.AboveNormal;
            _touchThread.Start();

            Open();

            _resetEvent.WaitOne();

            Close();

            return(_result);
        }