コード例 #1
0
ファイル: Tests.cs プロジェクト: cambell-prince/FieldWorks
        public void RememberOkBox()
        {
            string name = "X";

            using (MessageBoxEx msgBox = MessageBoxExManager.CreateMessageBox(name))
            {
                msgBox.Caption = name;
                msgBox.Text    = "Blah blah blah?";

                msgBox.AddButtons(MessageBoxButtons.YesNo);

                msgBox.SaveResponseText  = "Don't ask me again";
                msgBox.UseSavedResponse  = false;
                msgBox.AllowSaveResponse = true;

                //click the yes button when the dialog comes up
                m_FormTest.ExpectModal(name, ConfirmModalByYesAndRemember, true);

                Assert.AreEqual("Yes", msgBox.Show());

                m_FormTest.ExpectModal(name, DoNothing, false /*don't expect it, because it should use our saved response*/);
                msgBox.UseSavedResponse = true;
                Assert.AreEqual("Yes", msgBox.Show());
            }
        }
コード例 #2
0
ファイル: Tests.cs プロジェクト: sillsdev/WorldPad
        public void TimeoutOfNewBox()
        {
            string       name   = System.IO.Path.GetTempPath() /*just a hack to get a unique name*/;
            MessageBoxEx msgBox = MessageBoxExManager.CreateMessageBox(name);

            msgBox.Caption = "Question";
            msgBox.Text    = "Blah blah blah?";

            msgBox.AddButtons(MessageBoxButtons.YesNo);

            msgBox.Timeout       = 10;
            msgBox.TimeoutResult = TimeoutResult.Timeout;

            ExpectModal(name, "DoNothing", true);           //the nunitforms framework freaks out if we show a dialog with out warning it first
            Assert.AreEqual("Timeout", msgBox.Show());
        }
コード例 #3
0
ファイル: MessageBoxEx.cs プロジェクト: sillsdev/WorldPad
        /// <summary>
        /// Shows the messsage box with the specified owner
        /// </summary>
        /// <param name="owner"></param>
        /// <returns></returns>
        public string Show(IWin32Window owner)
        {
            if (_useSavedResponse && this.Name != null)
            {
                string savedResponse = MessageBoxExManager.GetSavedResponse(this);
                if (savedResponse != null)
                {
                    return(savedResponse);
                }
            }

            if (owner == null)
            {
                _msgBox.Name = this._name;                //needed for nunitforms support
                _msgBox.ShowDialog();
            }
            else
            {
                _msgBox.ShowDialog(owner);
            }

            if (this.Name != null)
            {
                if (_msgBox.AllowSaveResponse && _msgBox.SaveResponse)
                {
                    MessageBoxExManager.SetSavedResponse(this, _msgBox.Result);
                }
                else
                {
                    MessageBoxExManager.ResetSavedResponse(this.Name);
                }
            }
            else
            {
                Dispose();
            }

            return(_msgBox.Result);
        }
コード例 #4
0
ファイル: MessageBoxEx.cs プロジェクト: paulyc/megui
        /// <summary>
        /// Add a standard button to the message box
        /// </summary>
        /// <param name="buttons">The standard button to add</param>
        public void AddButton(MessageBoxExButtons button)
        {
            string buttonText = MessageBoxExManager.GetLocalizedString(button.ToString());

            if (buttonText == null)
            {
                buttonText = button.ToString();
            }

            string buttonVal = button.ToString();

            MessageBoxExButton btn = new MessageBoxExButton();

            btn.Text  = buttonText;
            btn.Value = buttonVal;

            if (button == MessageBoxExButtons.Cancel)
            {
                btn.IsCancelButton = true;
            }

            AddButton(btn);
        }
コード例 #5
0
ファイル: Tests.cs プロジェクト: cambell-prince/FieldWorks
 public void FixtureTearDown()
 {
     MessageBoxExManager.DisposeAllMessageBoxes();
 }